New StatusBar module does not support everything DynamicStatusBars did
mathstuf opened this issue · comments
Problem Description
Of note it assumes that it can kill a bar through killPid
which is not guaranteed. Instead, it should be some default that uses killPid
. My setup uses systemctl --user
to start and stop, so there's no pid to kill (and even if it did, systemd
would start it right up again.
Steps to Reproduce
Status bar cleanup needs to support a command to run to stop the status bars, not just some PID-run way (which is racy anyways).
Configuration File
Not really helpful here without the systemctl
setup.
Checklist
-
I've read CONTRIBUTING.md
-
I tested my configuration
- With
xmonad
version 0.17.0 - With
xmonad-contrib
version 0.17.0
- With
Cc: @TheMC47
Of note it assumes that it can kill a bar through
killPid
which is not guaranteed. Instead, it should be some default that useskillPid
.
I'm not sure if I misunderstood you, but isn't this exactly what we do? StatusBarConfig
has an sbCleanupHook
field, which one can customise in order to supply a different cleanup function.
(statusBarPropTo "_XMONAD_LOG_0" "xmobar -x 0" (xmobarPP 0)){ sbCleanupHook = … }
As @slotThe said, the X.H.StatusBar
has maximum flexibility and you can customize the behavior as you please: everything is X ()
. You could share your (old) config and I'm positive we can make it work with the new module.
Ah, I missed that sbCleanupHook
is a customization point. Sorry, just been so long since I've done Haskell work (I'm the original author of X.H.DynamicBars
). Let be poke at it a bit more (so that I better understand it myself)…
Awesome, X.H.DynamicBars
was a big help when writing the new module, thank you for that!
Ok, it seems I was able to do it. For anyone curious, here's the relevant diff from my config:
@@ -567,12 +569,25 @@ myFocusFollowsMouse = True
------------------------------------------------------------------------
-- Status bars and logging
-myLogHook :: X ()
-myLogHook = myLog
-
-myLog :: X ()
-myLog = multiPP focusPP unfocusPP
+myStatusBar :: ScreenId -> IO StatusBarConfig
+myStatusBar screen@(S id) = return $def
+ { sbLogHook = do
+ st <- get
+ let isFoc = (screen ==) . W.screen . W.current $ windowset st
+ let pp = if isFoc then focusPP else unfocusPP
+ xmonadPropLog' prop =<< dynamicLogString pp
+ , sbStartupHook = safeSpawn "systemctl" ["--user", "start", "xmobar@" ++ idStr ++ ".service"]
+ , sbCleanupHook = safeSpawn "systemctl" ["--user", "stop", "xmobar@" ++ idStr ++ ".service"]
+ }
where
+ prop = "_XMONAD_LOG_" ++ idStr
+ idStr = show id
focusPP = xmobarPP { ppTitle = xmobarColor "green" ""
, ppUrgent = xmobarColor "red" "" . xmobarStrip
, ppExtras = ppHook hookFloat
@@ -587,34 +602,17 @@ myLog = multiPP focusPP unfocusPP
]
s f fn@(ns:nl) = f fn (++ (' ' : (toUpper ns) : nl))
-myStatusBar :: DynamicStatusBar
-myStatusBar (S id) = do
- safeSpawn "systemctl" ["--user", "start", "xmobar@" ++ idStr ++ ".service"]
- spawnPipe $ "xmonadpropwrite " ++ prop
- where
- prop = "_XMONAD_LOG_" ++ idStr
- idStr = show id
-
-myStatusBarCleanup :: DynamicStatusBarPartialCleanup
-myStatusBarCleanup id = safeSpawn "systemctl" ["--user", "stop", "xmobar@" ++ idStr ++ ".service"]
- where
- idStr = show id
-
------------------------------------------------------------------------
-- Startup hook
myStartupHook :: X ()
myStartupHook = do
- docksStartupHook
- dynStatusBarStartup' myStatusBar myStatusBarCleanup
runLogHook
return ()
------------------------------------------------------------------------
-- Event hook
myEventHook :: Event -> X All
-myEventHook = docksEventHook <+> statusBarEventHook <+> hintsEventHook
- where
- statusBarEventHook = dynStatusBarEventHook' myStatusBar myStatusBarCleanup
+myEventHook = hintsEventHook
------------------------------------------------------------------------
-- Urgency settings
@@ -632,7 +630,7 @@ main = xmonad urgentConfig
------------------------------------------------------------------------
-- Set the values
-defaults = def
+defaults = docks . dynamicSBs myStatusBar $ def
-- simple stuff
{ terminal = myTerminalCmd
, focusFollowsMouse = myFocusFollowsMouse
@@ -649,7 +647,6 @@ defaults = def
-- hooks, layouts
, layoutHook = myLayout
, manageHook = myManageHook
- , logHook = myLogHook
, startupHook = myStartupHook
, handleEventHook = myEventHook
}
Awesome, X.H.DynamicBars was a big help when writing the new module, thank you for that!
This is certainly a better design where the status bar stuff is in one variable instead of strewn across a few of the hooks. The manual handle
storage is a bit unfortunate, but not much to be done about that I suspect.
Though looking, I need to close that handle too…
Just use https://xmonad.github.io/xmonad-docs/xmonad-contrib/XMonad-Hooks-StatusBar.html#v:xmonadPropLog-39- and drop all the handle nonsense ;-)
Oh, indeed. Thanks :) .
Patch hand-updated; the hunk metadata is wrong, but no one is applying that as-is anyways…