From 13b1de27a9128428e02054a1f7c8563a06da12cc Mon Sep 17 00:00:00 2001 From: Tomas Janousek Date: Thu, 3 Jun 2021 02:31:47 +0100 Subject: [PATCH] X.H.StatusBar: Add statusBarGeneric for taffybar/trayer/stalonetray `statusBarGeneric`: A generic `StatusBarConfig` that launches a status bar but takes a generic `X ()` logging function instead of a `PP`. This has several uses: * With `xmonadPropLog` or `xmonadPropLog'` in the logging function, a custom non-`PP`-based logger can be used for logging into an `xmobar`. * With `mempty` as the logging function, it's possible to manage a status bar that reads information from EWMH properties like `taffybar`. * With `mempty` as the logging function, any other dock like `trayer` or `stalonetray` can be managed by this module. Related: https://github.com/xmonad/xmonad-contrib/pull/463 --- XMonad/Hooks/StatusBar.hs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/XMonad/Hooks/StatusBar.hs b/XMonad/Hooks/StatusBar.hs index 720b4384..9e0faac1 100644 --- a/XMonad/Hooks/StatusBar.hs +++ b/XMonad/Hooks/StatusBar.hs @@ -34,6 +34,7 @@ module XMonad.Hooks.StatusBar ( -- $availableconfigs statusBarProp, statusBarPropTo, + statusBarGeneric, statusBarPipe, -- * Multiple Status Bars @@ -303,8 +304,25 @@ statusBarPropTo :: String -- ^ Property to write the string to -> String -- ^ The command line to launch the status bar -> X PP -- ^ The pretty printing options -> StatusBarConfig -statusBarPropTo prop cmd pp = def - { sbLogHook = xmonadPropLog' prop =<< dynamicLogString =<< pp +statusBarPropTo prop cmd pp = statusBarGeneric cmd $ + xmonadPropLog' prop =<< dynamicLogString =<< pp + +-- | A generic 'StatusBarConfig' that launches a status bar but takes a +-- generic @X ()@ logging function instead of a 'PP'. This has several uses: +-- +-- * With 'xmonadPropLog' or 'xmonadPropLog'' in the logging function, a +-- custom non-'PP'-based logger can be used for logging into an @xmobar@. +-- +-- * With 'mempty' as the logging function, it's possible to manage a status +-- bar that reads information from EWMH properties like @taffybar@. +-- +-- * With 'mempty' as the logging function, any other dock like @trayer@ or +-- @stalonetray@ can be managed by this module. +statusBarGeneric :: String -- ^ The command line to launch the status bar + -> X () -- ^ What and how to log to the status bar ('sbLogHook') + -> StatusBarConfig +statusBarGeneric cmd lh = def + { sbLogHook = lh , sbStartupHook = spawnStatusBar cmd , sbCleanupHook = killStatusBar cmd }