aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoman Cheplyaka <roma@ro-che.info>2008-02-10 23:24:06 +0100
committerRoman Cheplyaka <roma@ro-che.info>2008-02-10 23:24:06 +0100
commit35213ba07284d09ea5138c345696cdfcad2d6757 (patch)
treef4660674257ab3761e30c15873b210199ceec12c
parent85970665cd0728e4da535d72399bc1b95ea622fc (diff)
downloadXMonadContrib-35213ba07284d09ea5138c345696cdfcad2d6757.tar.gz
XMonadContrib-35213ba07284d09ea5138c345696cdfcad2d6757.tar.xz
XMonadContrib-35213ba07284d09ea5138c345696cdfcad2d6757.zip
Refactor XMonad.Hooks.DynamicLog
This allows using DynamicLog not only for statusbar. darcs-hash:20080210222406-3ebed-1943dc0ec95f1a630f89271b03b0a02c8918d5fd.gz
-rw-r--r--XMonad/Hooks/DynamicLog.hs19
1 files changed, 15 insertions, 4 deletions
diff --git a/XMonad/Hooks/DynamicLog.hs b/XMonad/Hooks/DynamicLog.hs
index def78e7..ed0b1ef 100644
--- a/XMonad/Hooks/DynamicLog.hs
+++ b/XMonad/Hooks/DynamicLog.hs
@@ -24,6 +24,7 @@ module XMonad.Hooks.DynamicLog (
makeSimpleDzenConfig,
dzen,
dynamicLog,
+ dynamicLogString,
dynamicLogDzen,
dynamicLogXmobar,
dynamicLogWithPP,
@@ -72,6 +73,11 @@ import XMonad.Hooks.UrgencyHook
-- > ...
-- > myDynamicLogPP = defaultPP { ... -- override pretty-printer with specific settings
--
+-- If you don't use statusbar, you can use dynamicLogString to show on-screen
+-- notifications in response to some events. E.g. to show current layout when
+-- it's changed create apropriate PP and add to keybindings:
+--
+-- > , ((mod1Mask, xK_a ), sendMessage NextLayout >> (dynamicLogString myPP >>= \d->spawn $"xmessage "++d))
-- | An example xmonad config that spawns a new dzen toolbar and uses
-- the default dynamic log output.
@@ -117,9 +123,9 @@ dynamicLog :: X ()
dynamicLog = dynamicLogWithPP defaultPP
-- |
--- A log function that uses the 'PP' hooks to customize output.
-dynamicLogWithPP :: PP -> X ()
-dynamicLogWithPP pp = do
+-- Returns formatted log message.
+dynamicLogString :: PP -> X String
+dynamicLogString pp = do
winset <- gets windowset
urgents <- readUrgents
sort' <- ppSort pp
@@ -130,12 +136,17 @@ dynamicLogWithPP pp = do
-- window title
wt <- maybe (return "") (fmap show . getName) . S.peek $ winset
- io . ppOutput pp . sepBy (ppSep pp) . ppOrder pp $
+ return $ sepBy (ppSep pp) . ppOrder pp $
[ ws
, ppLayout pp ld
, ppTitle pp wt
]
+-- |
+-- A log function that uses the 'PP' hooks to customize output.
+dynamicLogWithPP :: PP -> X ()
+dynamicLogWithPP pp = dynamicLogString pp >>= io . ppOutput pp
+
-- | An example log hook that emulates dwm's status bar, using colour
-- codes printed to dzen. Requires dzen. Workspaces, xinerama,
-- layouts and the window title are handled.