mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 03:20:21 -07:00
added dynamicLogXinerama, a workspace logger that's nicer for Xinerama
This commit is contained in:
parent
d18e7045e5
commit
fe70ba49d8
@ -14,7 +14,7 @@
|
||||
--
|
||||
-- Don Stewart
|
||||
|
||||
module XMonadContrib.DynamicLog where
|
||||
module XMonadContrib.DynamicLog (dynamicLog, dynamicLogXinerama) where
|
||||
|
||||
--
|
||||
-- Useful imports
|
||||
@ -38,14 +38,34 @@ import qualified StackSet as S
|
||||
dynamicLog :: X ()
|
||||
dynamicLog = withWindowSet $ io . putStrLn . ppr
|
||||
where
|
||||
ppr s = concatMap fmt $ sortBy tags
|
||||
ppr s = concatMap fmt $ sortBy (compare `on` S.tag)
|
||||
(map S.workspace (S.current s : S.visible s) ++ S.hidden s)
|
||||
where tags a b = S.tag a `compare` S.tag b
|
||||
this = S.tag (S.workspace (S.current s))
|
||||
pprTag = show . (+(1::Int)) . fromIntegral . S.tag
|
||||
where this = S.tag (S.workspace (S.current s))
|
||||
visibles = map (S.tag . S.workspace) (S.visible s)
|
||||
|
||||
fmt w | S.tag w == this = "[" ++ pprTag w ++ "]"
|
||||
| S.tag w `elem` visibles = "<" ++ pprTag w ++ ">"
|
||||
| S.stack w /= S.Empty = " " ++ pprTag w ++ " "
|
||||
| otherwise = ""
|
||||
|
||||
--
|
||||
-- Workspace logger with a format designed for Xinerama:
|
||||
--
|
||||
-- [1 9 3] 2 7
|
||||
--
|
||||
-- where 1, 9, and 3 are the workspaces on screens 1, 2 and 3, respectively,
|
||||
-- and 2 and 7 are non-visible, non-empty workspaces
|
||||
--
|
||||
dynamicLogXinerama :: X ()
|
||||
dynamicLogXinerama = withWindowSet $ io . putStrLn . ppr
|
||||
where
|
||||
ppr ws = "[" ++ unwords onscreen ++ "] " ++ unwords offscreen
|
||||
where onscreen = map (pprTag . S.workspace) . sortBy (compare `on` S.screen) $ S.current ws : S.visible ws
|
||||
offscreen = map pprTag . filter ((/= S.Empty) . S.stack) . sortBy (compare `on` S.tag) $ S.hidden ws
|
||||
|
||||
-- util functions
|
||||
pprTag :: Integral i => S.Workspace i a -> String
|
||||
pprTag = show . (+(1::Int)) . fromIntegral . S.tag
|
||||
|
||||
on :: (a -> a -> c) -> (b -> a) -> b -> b -> c
|
||||
on f g a b = (g a) `f` (g b)
|
||||
|
Loading…
x
Reference in New Issue
Block a user