X.H.StatusBar.PP: Clarify ppOutput doc + minor cleanups

This commit is contained in:
Tomas Janousek 2021-06-08 00:12:27 +01:00
parent c3b67ab0df
commit b6cd47db29
2 changed files with 5 additions and 4 deletions

View File

@ -335,9 +335,8 @@ statusBarPipe cmd xpp = do
return $ def
{ sbStartupHook = io (writeIORef hRef . Just =<< spawnPipe cmd)
, sbLogHook = do
pp <- xpp
h' <- io (readIORef hRef)
whenJust h' $ \h -> dynamicLogWithPP pp { ppOutput = hPutStrLn h }
whenJust h' $ \h -> io . hPutStrLn h =<< dynamicLogString =<< xpp
, sbCleanupHook = io
$ readIORef hRef
>>= (`whenJust` hClose)

View File

@ -128,7 +128,9 @@ data PP = PP { ppCurrent :: WorkspaceId -> String
-- output it. Can be used to specify an alternative
-- output method (e.g. write to a pipe instead of
-- stdout), and\/or to perform some last-minute
-- formatting.
-- formatting. Note that this is only used by
-- 'dynamicLogWithPP'; it won't work with 'dynamicLogString' or
-- "XMonad.Hooks.StatusBar".
}
-- | The default pretty printing options:
@ -179,7 +181,7 @@ dynamicLogString pp = do
let ws = pprWindowSet sort' urgents pp winset
-- run extra loggers, ignoring any that generate errors.
extras <- mapM (`catchX` return Nothing) $ ppExtras pp
extras <- mapM (userCodeDef Nothing) $ ppExtras pp
-- window title
wt <- maybe (pure "") (fmap show . getName) . S.peek $ winset