aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Hooks
diff options
context:
space:
mode:
authorShachaf Ben-Kiki <shachaf@gmail.com>2007-12-14 05:35:28 +0100
committerShachaf Ben-Kiki <shachaf@gmail.com>2007-12-14 05:35:28 +0100
commit65ac3274f02196d468328a27c16a3da174cd1650 (patch)
treec480592ef635b981897966058bf729e4012c2077 /XMonad/Hooks
parentfd16377fedf3c7f449d99a4f22d13fb6dab7aee7 (diff)
downloadXMonadContrib-65ac3274f02196d468328a27c16a3da174cd1650.tar.gz
XMonadContrib-65ac3274f02196d468328a27c16a3da174cd1650.tar.xz
XMonadContrib-65ac3274f02196d468328a27c16a3da174cd1650.zip
Add UrgencyHook support to DynamicLog
Someone with Xinerama should look at this -- I don't know exactly how that should behave. darcs-hash:20071214043528-bffde-d15c8db72fad65ce4d266917c3e22421fe45a5eb.gz
Diffstat (limited to 'XMonad/Hooks')
-rw-r--r--XMonad/Hooks/DynamicLog.hs28
1 files changed, 17 insertions, 11 deletions
diff --git a/XMonad/Hooks/DynamicLog.hs b/XMonad/Hooks/DynamicLog.hs
index 221b3cc..36f896d 100644
--- a/XMonad/Hooks/DynamicLog.hs
+++ b/XMonad/Hooks/DynamicLog.hs
@@ -49,6 +49,7 @@ import Data.Monoid
import System.IO
import XMonad.Util.NamedWindows
import XMonad.Util.Run
+import XMonad.Hooks.UrgencyHook
-- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
@@ -104,13 +105,15 @@ dynamicLog = dynamicLogWithPP defaultPP
-- A log function that uses the 'PP' hooks to customize output.
dynamicLogWithPP :: PP -> X ()
dynamicLogWithPP pp = do
+ winset <- gets windowset
+ urgents <- readUrgents
spaces <- asks (workspaces . config)
-- layout description
- ld <- withWindowSet $ return . description . S.layout . S.workspace . S.current
+ let ld = description . S.layout . S.workspace . S.current $ winset
-- workspace list
- ws <- withWindowSet $ return . pprWindowSet spaces pp
+ let ws = pprWindowSet spaces urgents pp winset
-- window title
- wt <- withWindowSet $ maybe (return "") (fmap show . getName) . S.peek
+ wt <- maybe (return "") (fmap show . getName) . S.peek $ winset
io . ppOutput pp . sepBy (ppSep pp) . ppOrder pp $
[ ws
@@ -124,9 +127,8 @@ dynamicLogWithPP pp = do
dynamicLogDzen :: X ()
dynamicLogDzen = dynamicLogWithPP dzenPP
-
-pprWindowSet :: [String] -> PP -> WindowSet -> String
-pprWindowSet spaces pp s = sepBy (ppWsSep pp) $ map fmt $ sortBy cmp
+pprWindowSet :: [String] -> [Window] -> PP -> WindowSet -> String
+pprWindowSet spaces urgents pp s = sepBy (ppWsSep pp) $ map fmt $ sortBy cmp
(map S.workspace (S.current s : S.visible s) ++ S.hidden s)
where f Nothing Nothing = EQ
f (Just _) Nothing = LT
@@ -141,10 +143,11 @@ pprWindowSet spaces pp s = sepBy (ppWsSep pp) $ map fmt $ sortBy cmp
visibles = map (S.tag . S.workspace) (S.visible s)
fmt w = printer pp (S.tag w)
- where printer | S.tag w == this = ppCurrent
- | S.tag w `elem` visibles = ppVisible
- | isJust (S.stack w) = ppHidden
- | otherwise = ppHiddenNoWindows
+ where printer | S.tag w == this = ppCurrent
+ | S.tag w `elem` visibles = ppVisible
+ | any (\x -> maybe False (== S.tag w) (S.findTag x s)) urgents = \pp -> ppUrgent pp . ppHidden pp
+ | isJust (S.stack w) = ppHidden
+ | otherwise = ppHiddenNoWindows
-- |
-- Workspace logger with a format designed for Xinerama:
@@ -198,7 +201,8 @@ xmobarColor fg bg = wrap t "</fc>"
-- | The 'PP' type allows the user to customize various behaviors of
-- dynamicLogPP
data PP = PP { ppCurrent, ppVisible
- , ppHidden, ppHiddenNoWindows :: WorkspaceId -> String
+ , ppHidden, ppHiddenNoWindows
+ , ppUrgent :: WorkspaceId -> String
, ppSep, ppWsSep :: String
, ppTitle :: String -> String
, ppLayout :: String -> String
@@ -212,6 +216,7 @@ defaultPP = PP { ppCurrent = wrap "[" "]"
, ppVisible = wrap "<" ">"
, ppHidden = id
, ppHiddenNoWindows = const ""
+ , ppUrgent = id
, ppSep = " : "
, ppWsSep = " "
, ppTitle = shorten 80
@@ -226,6 +231,7 @@ dzenPP = defaultPP { ppCurrent = dzenColor "white" "#2b4f98" . pad
, ppVisible = dzenColor "black" "#999999" . pad
, ppHidden = dzenColor "black" "#cccccc" . pad
, ppHiddenNoWindows = const ""
+ , ppUrgent = dzenColor "red" "yellow"
, ppWsSep = ""
, ppSep = ""
, ppLayout = dzenColor "black" "#cccccc" .