mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-21 23:13:48 -07:00
Factor out pprWindowSet (and Xinerama version) from dynamicLog.
This patch lets you pretty-print a WindowSet to a string, rather than always printing it out to stdout directly.
This commit is contained in:
@@ -21,7 +21,7 @@
|
|||||||
module XMonadContrib.DynamicLog (
|
module XMonadContrib.DynamicLog (
|
||||||
-- * Usage
|
-- * Usage
|
||||||
-- $usage
|
-- $usage
|
||||||
dynamicLog, dynamicLogXinerama
|
dynamicLog, dynamicLogXinerama, pprWindowSet, pprWindowSetXinerama
|
||||||
) where
|
) where
|
||||||
|
|
||||||
--
|
--
|
||||||
@@ -52,9 +52,10 @@ import qualified StackSet as S
|
|||||||
--
|
--
|
||||||
|
|
||||||
dynamicLog :: X ()
|
dynamicLog :: X ()
|
||||||
dynamicLog = withWindowSet $ io . putStrLn . ppr
|
dynamicLog = withWindowSet $ io . putStrLn . pprWindowSet
|
||||||
where
|
|
||||||
ppr s = concatMap fmt $ sortBy (compare `on` S.tag)
|
pprWindowSet :: WindowSet -> String
|
||||||
|
pprWindowSet s = concatMap fmt $ sortBy (compare `on` S.tag)
|
||||||
(map S.workspace (S.current s : S.visible s) ++ S.hidden s)
|
(map S.workspace (S.current s : S.visible s) ++ S.hidden s)
|
||||||
where this = S.tag (S.workspace (S.current s))
|
where this = S.tag (S.workspace (S.current s))
|
||||||
visibles = map (S.tag . S.workspace) (S.visible s)
|
visibles = map (S.tag . S.workspace) (S.visible s)
|
||||||
@@ -73,9 +74,10 @@ dynamicLog = withWindowSet $ io . putStrLn . ppr
|
|||||||
-- and 2 and 7 are non-visible, non-empty workspaces
|
-- and 2 and 7 are non-visible, non-empty workspaces
|
||||||
--
|
--
|
||||||
dynamicLogXinerama :: X ()
|
dynamicLogXinerama :: X ()
|
||||||
dynamicLogXinerama = withWindowSet $ io . putStrLn . ppr
|
dynamicLogXinerama = withWindowSet $ io . putStrLn . pprWindowSetXinerama
|
||||||
where
|
|
||||||
ppr ws = "[" ++ unwords onscreen ++ "] " ++ unwords offscreen
|
pprWindowSetXinerama :: WindowSet -> String
|
||||||
|
pprWindowSetXinerama ws = "[" ++ unwords onscreen ++ "] " ++ unwords offscreen
|
||||||
where onscreen = map (pprTag . S.workspace)
|
where onscreen = map (pprTag . S.workspace)
|
||||||
. sortBy (compare `on` S.screen) $ S.current ws : S.visible ws
|
. sortBy (compare `on` S.screen) $ S.current ws : S.visible ws
|
||||||
offscreen = map pprTag . filter (isJust . S.stack)
|
offscreen = map pprTag . filter (isJust . S.stack)
|
||||||
|
Reference in New Issue
Block a user