mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
Port DynamicLog
This commit is contained in:
parent
0b681cadc2
commit
e16479570a
@ -38,8 +38,7 @@ module XMonadContrib.DynamicLog (
|
|||||||
-- Useful imports
|
-- Useful imports
|
||||||
--
|
--
|
||||||
import XMonad
|
import XMonad
|
||||||
import {-# SOURCE #-} Config (workspaces)
|
import Control.Monad.Reader
|
||||||
import Operations () -- for ReadableSomeLayout instance
|
|
||||||
import Data.Maybe ( isJust )
|
import Data.Maybe ( isJust )
|
||||||
import Data.List
|
import Data.List
|
||||||
import Data.Ord ( comparing )
|
import Data.Ord ( comparing )
|
||||||
@ -74,10 +73,11 @@ dynamicLog = dynamicLogWithPP defaultPP
|
|||||||
-- A log function that uses the 'PP' hooks to customize output.
|
-- A log function that uses the 'PP' hooks to customize output.
|
||||||
dynamicLogWithPP :: PP -> X ()
|
dynamicLogWithPP :: PP -> X ()
|
||||||
dynamicLogWithPP pp = do
|
dynamicLogWithPP pp = do
|
||||||
|
spaces <- asks (workspaces . config)
|
||||||
-- layout description
|
-- layout description
|
||||||
ld <- withWindowSet $ return . description . S.layout . S.workspace . S.current
|
ld <- withWindowSet $ return . description . S.layout . S.workspace . S.current
|
||||||
-- workspace list
|
-- workspace list
|
||||||
ws <- withWindowSet $ return . pprWindowSet pp
|
ws <- withWindowSet $ return . pprWindowSet spaces pp
|
||||||
-- window title
|
-- window title
|
||||||
wt <- withWindowSet $ maybe (return "") (fmap show . getName) . S.peek
|
wt <- withWindowSet $ maybe (return "") (fmap show . getName) . S.peek
|
||||||
|
|
||||||
@ -94,15 +94,15 @@ dynamicLogDzen :: X ()
|
|||||||
dynamicLogDzen = dynamicLogWithPP dzenPP
|
dynamicLogDzen = dynamicLogWithPP dzenPP
|
||||||
|
|
||||||
|
|
||||||
pprWindowSet :: PP -> WindowSet -> String
|
pprWindowSet :: [String] -> PP -> WindowSet -> String
|
||||||
pprWindowSet pp s = sepBy (ppWsSep pp) $ map fmt $ sortBy cmp
|
pprWindowSet spaces pp s = sepBy (ppWsSep pp) $ map fmt $ sortBy cmp
|
||||||
(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 f Nothing Nothing = EQ
|
where f Nothing Nothing = EQ
|
||||||
f (Just _) Nothing = LT
|
f (Just _) Nothing = LT
|
||||||
f Nothing (Just _) = GT
|
f Nothing (Just _) = GT
|
||||||
f (Just x) (Just y) = compare x y
|
f (Just x) (Just y) = compare x y
|
||||||
|
|
||||||
wsIndex = flip elemIndex workspaces . S.tag
|
wsIndex = flip elemIndex spaces . S.tag
|
||||||
|
|
||||||
cmp a b = f (wsIndex a) (wsIndex b) `mappend` compare (S.tag a) (S.tag b)
|
cmp a b = f (wsIndex a) (wsIndex b) `mappend` compare (S.tag a) (S.tag b)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user