From ebfc068b9978882b2c72f06b8824270afc0fc404 Mon Sep 17 00:00:00 2001 From: ivanbrennan Date: Tue, 15 Sep 2020 09:14:58 -0400 Subject: [PATCH] DynamicLog: statusBar' Add a statusBar' function that accepts pretty printing options embedded in the X monad, so users can leverage dynamic printing modifiers, such as workspaceNamesPP. --- XMonad/Hooks/DynamicLog.hs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/XMonad/Hooks/DynamicLog.hs b/XMonad/Hooks/DynamicLog.hs index 2c072e54..a1976c64 100644 --- a/XMonad/Hooks/DynamicLog.hs +++ b/XMonad/Hooks/DynamicLog.hs @@ -27,6 +27,7 @@ module XMonad.Hooks.DynamicLog ( dzenWithFlags, xmobar, statusBar, + statusBar', dynamicLog, dynamicLogXinerama, @@ -223,12 +224,25 @@ statusBar :: LayoutClass l Window -- ^ the desired key binding to toggle bar visibility -> XConfig l -- ^ the base config -> IO (XConfig (ModifiedLayout AvoidStruts l)) -statusBar cmd pp k conf = do +statusBar cmd pp = statusBar' cmd (return pp) + +-- | Like 'statusBar' with the pretty printing options embedded in the +-- X monad. The X PP value is re-executed every time the 'logHook' runs. +-- Useful if printing options need to be modified dynamically. +statusBar' :: LayoutClass l Window + => String -- ^ the command line to launch the status bar + -> X PP -- ^ the pretty printing options + -> (XConfig Layout -> (KeyMask, KeySym)) + -- ^ the desired key binding to toggle bar visibility + -> XConfig l -- ^ the base config + -> IO (XConfig (ModifiedLayout AvoidStruts l)) +statusBar' cmd xpp k conf = do h <- spawnPipe cmd return $ docks $ conf { layoutHook = avoidStruts (layoutHook conf) , logHook = do logHook conf + pp <- xpp dynamicLogWithPP pp { ppOutput = hPutStrLn h } , keys = liftA2 M.union keys' (keys conf) }