From aff075e22fba55a405b3a0ed2b1b095615077150 Mon Sep 17 00:00:00 2001 From: "Ivan N. Veselov" Date: Thu, 8 May 2008 21:49:18 +0200 Subject: 'xmobar' function added to DynamicLog for running xmobar with some defaults darcs-hash:20080508194918-98257-90af4d9fa986c220fbac658d04d14a8e78f231f9.gz --- XMonad/Hooks/DynamicLog.hs | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) (limited to 'XMonad/Hooks') diff --git a/XMonad/Hooks/DynamicLog.hs b/XMonad/Hooks/DynamicLog.hs index a7fcd83..621651d 100644 --- a/XMonad/Hooks/DynamicLog.hs +++ b/XMonad/Hooks/DynamicLog.hs @@ -22,6 +22,7 @@ module XMonad.Hooks.DynamicLog ( -- * Drop-in loggers dzen, + xmobar, dynamicLog, dynamicLogDzen, dynamicLogXmobar, @@ -80,6 +81,9 @@ import XMonad.Hooks.ManageDocks -- -- > main = dzen $ \conf -> xmonad $ conf { } -- +-- Also you can use 'xmobar' function instead of 'dzen' in the examples above, +-- if you have xmobar installed. +-- -- Alternatively, you can choose among several default status bar -- formats ('dynamicLog', 'dynamicLogDzen', 'dynamicLogXmobar', or -- 'dynamicLogXinerama') by simply setting your logHook to the @@ -150,7 +154,7 @@ import XMonad.Hooks.ManageDocks -- use something like 'dynamicLogWithPP' instead. -- -- The binding uses the XMonad.Hooks.ManageDocks module to automatically --- handle screen placement for dzen, and enables 'mod-b' for toggling +-- handle screen placement for dzen, and enables 'mod-b' for toggling -- the menu bar. -- dzen :: @@ -163,17 +167,42 @@ dzen f = do { logHook = dynamicLogWithPP dzenPP { ppOutput = hPutStrLn h } ,layoutHook = avoidStrutsOn [U] (layoutHook defaultConfig) - ,keys = \c -> mykeys c `M.union` keys defaultConfig c + ,keys = \c -> toggleStrutsKey c `M.union` keys defaultConfig c ,manageHook = manageHook defaultConfig <+> manageDocks } where - mykeys (XConfig{modMask=modm}) = M.fromList - [((modm, xK_b ), sendMessage ToggleStruts) - ] fg = "'#a8a3f7'" -- n.b quoting bg = "'#3f3c6d'" flags = "-e 'onstart=lower' -w 400 -ta l -fg " ++ fg ++ " -bg " ++ bg + +-- | Run xmonad with a xmobar status bar set to some nice defaults. Output +-- is taken from the dynamicLogWithPP hook. +-- +-- > main = xmobar xmonad +-- +-- This works pretty much the same as 'dzen' function above +-- +xmobar :: + (XConfig + (ModifiedLayout AvoidStruts + (Choose Tall (Choose (Mirror Tall) Full))) -> IO t) -> IO t +xmobar f = do + h <- spawnPipe "xmobar" + f $ defaultConfig + { logHook = dynamicLogWithPP xmobarPP { ppOutput = hPutStrLn h } + , layoutHook = avoidStruts $ layoutHook defaultConfig + , keys = \c -> toggleStrutsKey c `M.union` keys defaultConfig c + , manageHook = manageHook defaultConfig <+> manageDocks + } + +-- | +-- Helper function which provides ToggleStruts keybinding +-- +toggleStrutsKey :: XConfig t -> M.Map (KeyMask, KeySym) (X ()) +toggleStrutsKey XConfig{modMask = modm} = M.fromList + [ ((modm, xK_b ), sendMessage ToggleStruts) ] + ------------------------------------------------------------------------ -- | An example log hook, which prints status information to stdout in -- cgit v1.2.3