Multi-Monitor issues with XMonad.Hooks.DynamicBars and xmobar

Hello all, I bought a new second monitor and got an issue with my dynamic xmobar setup. I use a laptop which is connected to both monitors via a docking station. This is the configuration I want to achieve with independent bars on monitor one and two. Note: when docked I do not want to turn the internal display off, this has to be done in order to save a configuration in autorandr. If anyone has a suggestion to avoid this problem, feel free to share. Configuration of xrandr(autorandr): 1. Undocked Internal display primary output 1. Docked Internal display off First monitor set as primary Second monitor right of first monitor Xmonad Configuration: main :: IO () main = xmonad . ewmh . withUrgencyHook NoUrgencyHook . dynamicEasySBs (pure . barSpawner) . usePrefixArgument "M-u" . rescreenHook def{ afterRescreenHook = onMonitorChange } . spawnExternalProcess def $ myConfig `additionalKeysP` myKeys where barSpawner :: ScreenId -> StatusBarConfig barSpawner = \case 0 -> statusBarPropTo "_XMONAD_LOG_0" "~/.local/bin/xmobar ~/.config/xmobar/xmobar-old/xmobarrc -x 0" (xmobarPP 0) 1 -> statusBarPropTo "_XMONAD_LOG_1" "~/.local/bin/xmobar ~/.config/xmobar/xmobar-old/xmobarrc1 -x 1" (xmobarPP 1) _ -> mempty onMonitorChange :: X () onMonitorChange = do spawn "autorandr --change" Issue: When I plug my laptop into the docking station my rescreenHook gets executed which invokes autorandr to load my specified profiles, which - when docked - applies the rules for my docked configuration shown above. Xmobar spawns on monitor with ID 1 and indicates, that there is also a second monitor displaying a different workspace but somehow there is no xmobar present on the other monitor (ID 0). When I run the command defined in my barSpawner for monitor ID 0, the xmobar is spawned and works perfectly fine. Thanks for your help Jan

Hi Jan, On Mon, Mar 11, 2024 at 05:44:56PM +0000, Jan Detke wrote:
[…] When I plug my laptop into the docking station my rescreenHook gets executed which invokes autorandr to load my specified profiles, which - when docked - applies the rules for my docked configuration shown above. Xmobar spawns on monitor with ID 1 and indicates, that there is also a second monitor displaying a different workspace but somehow there is no xmobar present on the other monitor (ID 0). When I run the command defined in my barSpawner for monitor ID 0, the xmobar is spawned and works perfectly fine.
The X.H.StatusBar machinery does not normally restart bars that are already running. It leaves it up to xmobar itself to notice xrandr layout changes and to reposition themselves. That usually works fine but yeah I got to admit I've seen xmobar fail to reposition itself. I think I even spent some time trying to fix that but concluded it's some weird race condition in the X server or Xlib itself that's preventing it from seeing the correct layout info. Anyway, you can try to add [killAllStatusBars](https://xmonad.github.io/xmonad-docs/xmonad-contrib/XMonad-Hooks-StatusBar.h...) to your `afterRescreenHook`, and that should cause all bars to be restarted. -- Tomáš "liskin" ("Pivník") Janoušek, https://lisk.in/
participants (2)
-
Jan Detke
-
Tomas Janousek