Skip to content

Github module displays label when offline #1815

@kopecs

Description

@kopecs

Describe the issue

When offline the github module displays regardless of empty-notifications = false.

Expected behavior:

The module either displays only when the last query resulted in a non-zero number of notifications or does not display even when offline (alternatively, allows for a custom offline label to be set).

Actual behavior:

Github module always displays when offline.

Was it working before?

Same behavior since I've first used github module (~3 weeks).

  • Did you also experience this bug in an earlier version of polybar?

Yes.

  • If no, what was the last version where this worked correctly?

To Reproduce

A minimal but complete config with which the problem occurs:

[colors]
background = #222
background-alt = #444
foreground = #dfdfdf
foreground-alt = #888
primary = #ffb52a
secondary = #e60053
alert = #bd2c40

[bar/main]
monitor = ${env:MONITOR:eDP-1}
width = 100%
height = 2.5%
radius = 6.0
fixed-center = false
bottom = true

background = ${colors.background}
foreground = ${colors.foreground}

border-size = 0
line-size = 2
padding = 1
module-margin = 1

font-0 = "Noto Sans Mono:size=10;1"
font-1 = "Noto Sans Mono:size=10;1"
font-2 = "Noto Sans Symbols:size=10;1"
font-3 = "Noto Sans Symbols2:size=10;1"

modules-left = 
modules-center =
modules-right = github

tray-position = right
tray-padding = 2
tray-maxsize = 24

[global/wm]
margin-top = 0

[module/github]
type = internal/github
token = ${file:~/.config/github/notifications.token}
empty-notifications = false
;label = %{u#ff9900 +u} %notifications% %{u-}
label = %{u#0099ff +u} 📫 %{u-}
interval = 10

[settings]
screenchange-reload = true

; vim:ft=dosini

List any other steps needed to reproduce the issue besides starting polybar with the config you posted above.

Disconnect any internet connection.

Polybar Log

Post everything polybar outputs to the terminal when you run it and the issue occurs below

warn: module/github: cannot complete the request to github: Couldn't connect to server

Screenshots

If applicable, add screenshots to help explain your problem.
With full config:

  • Online (No notifications):
    2019-06-17-165021_1919x23_scrot
  • Offline:
    2019-06-17-165110_1919x22_scrot

Environment:

  • WM: xmonad 0.15-12
  • Distro: Arch Linux
  • Output of polybar -vvv:

polybar 3.3.1

Features: +alsa +curl -i3 -mpd +network(libnl) +pulseaudio +xkeyboard

X extensions: +randr (+monitors) -render -damage -sync +composite +xkb +xrm +xcursor

Build type: RelWithDebInfo
Compiler: /usr/bin/c++
Compiler flags: -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -Wall -Wextra -Werror -Wno-noexcept-type -pedantic -pedantic-errors
Linker flags: -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now

Additional context

Add any other context that you think is necessary about the problem here.
Appears to occur as a result of drawing whenever the condition in line 81 of github.cpp is met (0 != notifications || m_empty_notifications), in conjunction with the choice to return -1 from get_number_of_notifications when a non 200 http response is received and passing that directly to update_label.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions