-
-
Notifications
You must be signed in to change notification settings - Fork 723
Description
Describe the issue
The xworkspaces module will show one desktop/workspace too many when the window manager does not provide workspace names (such as 2bwm).
Expected behavior:
The number of workspaces displayed should be equal to the actual number of workspaces.
Actual behavior:
When no names are provided the number of names is smaller than the number of workspaces.
This results in the names vector being filled with n+1 values even though there are only n workspaces thus adding one name too many.
polybar/src/modules/xworkspaces.cpp
Lines 234 to 247 in d93a508
| vector<string> xworkspaces_module::get_desktop_names() { | |
| vector<string> names = ewmh_util::get_desktop_names(); | |
| unsigned int desktops_number = ewmh_util::get_number_of_desktops(); | |
| if (desktops_number == names.size()) { | |
| return names; | |
| } else if (desktops_number < names.size()) { | |
| names.erase(names.begin() + desktops_number, names.end()); | |
| return names; | |
| } | |
| for (unsigned int i = names.size(); i < desktops_number + 1; i++) { | |
| names.insert(names.end(), to_string(i)); | |
| } | |
| return names; | |
| } |
The +1 would need to be removed.
Was it working before?
No, this bug existed since the xworkspaces module was merged.
To Reproduce
A minimal but complete config with which the problem occurs:
[bar/example]
center = ewmh
[module/ewmh]
type = internal/xworkspaces
pin-workspaces = falseA window manager that doesn't set workspace names such as 2bwm is necessary.
Default 2bwm will have 10 workspaces so the bar will display 11 instead.
Polybar Log
No relevant logs since no crashes etc occur.
Environment:
- WM: 2bwm
- Distro: Arch
polybar -vvv:
polybar 3.4.0-57-g2cbbc86
Features: +alsa +curl +i3 +mpd +network(libnl) +pulseaudio +xkeyboard
X extensions: +randr (+monitors) +composite +xkb +xrm +xcursor
Build type: Release
Compiler: /usr/bin/c++
Compiler flags: -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -Wall -Wextra -Wpedantic -O3 -DNDEBUG
Linker flags: -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now