polybar: Polybar shows on wrong monitor after hide
Describe the issue
When the polybar hides and then shows again it appears on the wrong monitor.
Expected behavior:
The hidden polybars should be appearing on the same monitor on which they were hidden.
Actual behavior:
Running polybar-msg cmd toggle twice makes all the polybars from all my monitors show up on a single monitor.
To Reproduce
A minimal but complete config with which the problem occurs:
# File: ~/.config/polybar/config
[bar/middle]
monitor = ${env:MONITOR_MIDDLE}
[bar/right]
inherit = bar/middle
monitor = ${env:MONITOR_RIGHT}
# File: ~/.profile
# Monitors
export MONITOR_MIDDLE=DP-2
export MONITOR_RIGHT=DVI-D-0
Screenshots

Environment:
- WM: i3-gaps
polybar 3.2.1
Features: +alsa +curl +i3 +mpd +network +pulseaudio +xkeyboard
X extensions: +randr (+monitors) -render -damage -sync -composite +xkb +xrm +xcursor
Build type: RelWithDebInfo
Compiler: /usr/sbin/c++
Compiler flags: -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -Wall -Wextra -Werror -Wno-noexcept-type -O2 -pedantic -pedantic-errors
Linker flags: -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 22 (18 by maintainers)
Commits related to this issue
- fix(bar): Configure position before remapping Some WMs like i3 discard position information when unmapping the bar and because of that the bar would be at the wrong position after being remapped. Fi... — committed to patrick96/polybar by patrick96 5 years ago
- fix(bar): Configure window before remapping Some WMs like i3 discard position information when unmapping the bar and because of that the bar would be at the wrong position after being remapped. Fixe... — committed to patrick96/polybar by patrick96 5 years ago
- fix(bar): Configure window before remapping Some WMs like i3 discard position information when unmapping the bar and because of that the bar would be at the wrong position after being remapped. Fixe... — committed to polybar/polybar by patrick96 5 years ago
- fix(bar): Configure window before remapping Some WMs like i3 discard position information when unmapping the bar and because of that the bar would be at the wrong position after being remapped. Fixe... — committed to patrick96/polybar by patrick96 5 years ago
- Release 3.4.1 Changelog Dependencies We dropped `python2` as a dependency, just in time for its EOL. Now the only python dependency is `python3` (#1908). Fixes * ipc: * Update bar when making ... — committed to patrick96/polybar by patrick96 5 years ago
- Release 3.4.1 Changelog Dependencies: We dropped `python2` as a dependency, just in time for its EOL. Now the only python dependency is `python3` (#1908). Fixes: * ipc: * Update bar when maki... — committed to patrick96/polybar by patrick96 5 years ago
- fix(bar): Configure window before remapping Some WMs like i3 discard position information when unmapping the bar and because of that the bar would be at the wrong position after being remapped. Fixe... — committed to polybar/polybar by patrick96 5 years ago
- Release 3.4.1 Changelog Dependencies: We dropped `python2` as a dependency, just in time for its EOL. Now the only python dependency is `python3` (#1908). Fixes: * ipc: * Update bar when maki... — committed to polybar/polybar by patrick96 5 years ago
The fix in i3 is merged now. Thanks everyone 😃
@Airblader Now that I read my comment again it does sound demeaning. I’m sorry about that, it certainly was not meant that way.
Polybar sets the x and y coordinates of the window to position it on the screen. It calculates those coordinates from the monitor specified in the config (or the primary monitor). So for example if I had two 1920p monitors side-by-side and polybar on the monitor on the right at the top, it would set its geometry as
1920x50+1920+0(assuming it is 50px high). As far as I know we don’t use the monitor name for anything else when positioning the bars. Does i3 need polybar to explicitly set the monitor name somewhere?I am currently on my way back from vacation, so I don’t have much time to track this down right now but I will try to dig into this and give a more in-depth answer tonight or tomorrow.
Sorry again, I didn’t mean to attack anyone. I’m very much a fan of your and the i3 team’s work. I hope we can fix this issue together.
I can’t say I appreciate @patrick96’s tone, but in trying to hunt this down I would appreciate if someone could tell us what it is polybar does that is supposed to let the window manager know onto which output to place the bar.
From the log file provided by @jluttine in https://github.com/i3/i3/issues/3819 it appears that polybar sets the geometry to x=0/y=0 for both windows, so I guess the geometry when mapping the window is not what polybar tries to use(?)
Your PR works for this issue. I have nonetheless added a fix within polybar since there are likely other WMs that do a similar thing.
In the log files, there are four polybar windows being mapped in total, grouped into two events: one at 10:45:27 and one at 10:45:43. The logs above are from the latter one.
Out of all four requests, there is only one with an initial geometry of x != 0:
But this is from the first of the two events(?) and also it can be seen that that one actually shows at HDMI-1 while all others go to eDP-1, so it sort of sounds like i3 is doing the correct thing.
No,
polybar-msg cmd restartshould not break anythingAlright, so it is in fact i3 messing everything up (as usual).
It seems your only option is to leave this option set to
trueand use a transparent dummy bar to make i3 reserve space for your bars as described here. Then, if you hide the bars, you will have to kill the dummy bars and restart them once you show the bars again. This way i3 can reclaim the space when you hide the bars.