Restart all xmobars on every XMonad screen change
dynamicEasySBs kept bars for existing screen ids, so the bar started before screen-layout ran kept the laptop config on HDMI.
This commit is contained in:
@@ -35,7 +35,8 @@ main =
|
||||
. ewmhFullscreen
|
||||
. setEwmhSwitchDesktopHook W.greedyView
|
||||
. ewmh
|
||||
. dynamicEasySBs myStatusBars
|
||||
. docks
|
||||
. addAfterRescreenHook restartStatusBars
|
||||
. addRandrChangeHook (spawn myScreenHotplug)
|
||||
$ myConfig
|
||||
|
||||
@@ -182,13 +183,20 @@ myLayoutHook = onWorkspace wsWeb myWebLayout $ onWorkspace wsGames myGamesLayout
|
||||
delta = 3 / 100
|
||||
|
||||
-- Xmobar
|
||||
-- One bar per connected screen. The laptop config leaves room for trayer, so it
|
||||
-- goes on the laptop screen, which is screen 1 with HDMI and screen 0 without.
|
||||
myStatusBars :: ScreenId -> X StatusBarConfig
|
||||
myStatusBars (S i) = do
|
||||
nScreens <- gets (length . W.screens . windowset)
|
||||
let rc = if nScreens > 1 && i /= 1 then "xmobarrc_hdmi" else "xmobarrc_laptop"
|
||||
pure $ statusBarProp ("xmobar -x " ++ show i ++ " ~/.config/xmobar/" ++ rc) (clickablePP myXmobarPP)
|
||||
-- The laptop config leaves room for trayer, so it goes on the laptop screen,
|
||||
-- which is screen 1 with HDMI and screen 0 without.
|
||||
myStatusBar :: Int -> Int -> String
|
||||
myStatusBar nScreens i = "xmobar -x " ++ show i ++ " ~/.config/xmobar/" ++ rc
|
||||
where
|
||||
rc = if nScreens > 1 && i /= 1 then "xmobarrc_hdmi" else "xmobarrc_laptop"
|
||||
|
||||
-- One bar per screen, all restarted on every screen change: the right config for a
|
||||
-- screen id depends on the screen count, and dynamicSBs would keep the old bar
|
||||
restartStatusBars :: X ()
|
||||
restartStatusBars = do
|
||||
killAllStatusBars
|
||||
screens <- gets (W.screens . windowset)
|
||||
forM_ screens $ \s -> let S i = W.screen s in spawnStatusBar (myStatusBar (length screens) i)
|
||||
|
||||
myXmobarPP :: PP
|
||||
myXmobarPP =
|
||||
@@ -219,6 +227,7 @@ myXmobarPP =
|
||||
-- Autostart
|
||||
myStartupHook :: X ()
|
||||
myStartupHook = do
|
||||
restartStatusBars
|
||||
spawnOnce myScreenSetup
|
||||
spawnOnce "xsetroot -cursor_name left_ptr"
|
||||
spawnOnce "xautolock -time 10 -locker slock -detectsleep"
|
||||
@@ -289,7 +298,9 @@ myHandleEventHook =
|
||||
|
||||
-- Log hook
|
||||
myLogHook :: X ()
|
||||
myLogHook = raiseDiscoverOverlay
|
||||
myLogHook = do
|
||||
raiseDiscoverOverlay
|
||||
xmonadPropLog =<< dynamicLogString =<< clickablePP myXmobarPP
|
||||
|
||||
-- discover-overlay's windows are override-redirect, so xmonad doesn't manage them and
|
||||
-- raising a floating window (e.g. a game) covers them; put them back on top after every change
|
||||
|
||||
Reference in New Issue
Block a user