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
|
. ewmhFullscreen
|
||||||
. setEwmhSwitchDesktopHook W.greedyView
|
. setEwmhSwitchDesktopHook W.greedyView
|
||||||
. ewmh
|
. ewmh
|
||||||
. dynamicEasySBs myStatusBars
|
. docks
|
||||||
|
. addAfterRescreenHook restartStatusBars
|
||||||
. addRandrChangeHook (spawn myScreenHotplug)
|
. addRandrChangeHook (spawn myScreenHotplug)
|
||||||
$ myConfig
|
$ myConfig
|
||||||
|
|
||||||
@@ -182,13 +183,20 @@ myLayoutHook = onWorkspace wsWeb myWebLayout $ onWorkspace wsGames myGamesLayout
|
|||||||
delta = 3 / 100
|
delta = 3 / 100
|
||||||
|
|
||||||
-- Xmobar
|
-- Xmobar
|
||||||
-- One bar per connected screen. The laptop config leaves room for trayer, so it
|
-- The laptop config leaves room for trayer, so it goes on the laptop screen,
|
||||||
-- goes on the laptop screen, which is screen 1 with HDMI and screen 0 without.
|
-- which is screen 1 with HDMI and screen 0 without.
|
||||||
myStatusBars :: ScreenId -> X StatusBarConfig
|
myStatusBar :: Int -> Int -> String
|
||||||
myStatusBars (S i) = do
|
myStatusBar nScreens i = "xmobar -x " ++ show i ++ " ~/.config/xmobar/" ++ rc
|
||||||
nScreens <- gets (length . W.screens . windowset)
|
where
|
||||||
let rc = if nScreens > 1 && i /= 1 then "xmobarrc_hdmi" else "xmobarrc_laptop"
|
rc = if nScreens > 1 && i /= 1 then "xmobarrc_hdmi" else "xmobarrc_laptop"
|
||||||
pure $ statusBarProp ("xmobar -x " ++ show i ++ " ~/.config/xmobar/" ++ rc) (clickablePP myXmobarPP)
|
|
||||||
|
-- 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 :: PP
|
||||||
myXmobarPP =
|
myXmobarPP =
|
||||||
@@ -219,6 +227,7 @@ myXmobarPP =
|
|||||||
-- Autostart
|
-- Autostart
|
||||||
myStartupHook :: X ()
|
myStartupHook :: X ()
|
||||||
myStartupHook = do
|
myStartupHook = do
|
||||||
|
restartStatusBars
|
||||||
spawnOnce myScreenSetup
|
spawnOnce myScreenSetup
|
||||||
spawnOnce "xsetroot -cursor_name left_ptr"
|
spawnOnce "xsetroot -cursor_name left_ptr"
|
||||||
spawnOnce "xautolock -time 10 -locker slock -detectsleep"
|
spawnOnce "xautolock -time 10 -locker slock -detectsleep"
|
||||||
@@ -289,7 +298,9 @@ myHandleEventHook =
|
|||||||
|
|
||||||
-- Log hook
|
-- Log hook
|
||||||
myLogHook :: X ()
|
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
|
-- 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
|
-- 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