[xmonad] Multi-Monitor issues with XMonad.Hooks.DynamicBars and xmobar

Jan Detke jandetke at outlook.com
Mon Mar 11 17:44:56 UTC 2024


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


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/xmonad/attachments/20240311/efa2b767/attachment.html>


More information about the xmonad mailing list