From e31b1b338e0b0b97485270e9391276e545b4459c Mon Sep 17 00:00:00 2001 From: Devin Mullins Date: Sat, 3 Nov 2007 03:17:05 +0100 Subject: add haddock for top-level Dzen bindings darcs-hash:20071103021705-78224-46622e42710b1529e4d9a51aaa1775ba9743be50.gz --- Dzen.hs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'Dzen.hs') diff --git a/Dzen.hs b/Dzen.hs index 69729b2..911abbd 100644 --- a/Dzen.hs +++ b/Dzen.hs @@ -27,20 +27,28 @@ import XMonad import XMonadContrib.NamedWindows (getName) import XMonadContrib.Run (runProcessWithInputAndWait, seconds) -toXineramaArg :: ScreenId -> String -toXineramaArg n = show ( ((fromIntegral n)+1)::Int ) - -- | @dzen str timeout@ pipes @str@ to dzen2 for @timeout@ microseconds. -- Example usage: -- > dzen "Hi, mom!" (5 `seconds`) dzen :: String -> Int -> X () dzen str timeout = dzenWithArgs str [] timeout +-- | @dzen str args timeout@ pipes @str@ to dzen2 for @timeout@ seconds, passing @args@ to dzen. +-- Example usage: +-- > dzen "Hi, dons!" ["-ta", "r"] (5 `seconds`) +dzenWithArgs :: String -> [String] -> Int -> X () +dzenWithArgs str args timeout = io $ runProcessWithInputAndWait "dzen2" args (unchomp str) timeout + -- dzen seems to require the input to terminate with exactly one newline. + where unchomp s@['\n'] = s + unchomp [] = ['\n'] + unchomp (c:cs) = c : unchomp cs + -- | @dzenScreen sc str timeout@ pipes @str@ to dzen2 for @timeout@ microseconds, and on screen @sc@. -- Requires dzen to be compiled with Xinerama support. dzenScreen :: ScreenId -> String -> Int -> X() dzenScreen sc str timeout = dzenWithArgs str ["-xs", screen] timeout where screen = toXineramaArg sc + toXineramaArg n = show ( ((fromIntegral n)+1)::Int ) -- | Flashes when a window requests your attention and you can't see it. For use with -- XMonadContrib.UrgencyHook. Usage: @@ -48,6 +56,9 @@ dzenScreen sc str timeout = dzenWithArgs str ["-xs", screen] timeout dzenUrgencyHook :: Int -> Window -> X () dzenUrgencyHook = dzenUrgencyHookWithArgs [] +-- | Flashes when a window requests your attention and you can't see it. For use with +-- XMonadContrib.UrgencyHook. Usage: +-- > urgencyHook = dzenUrgencyHook ["-bg", "darkgreen"] (5 `seconds`) dzenUrgencyHookWithArgs :: [String] -> Int -> Window -> X () dzenUrgencyHookWithArgs args duration w = do visibles <- gets mapped @@ -58,10 +69,3 @@ dzenUrgencyHookWithArgs args duration w = do when (not $ S.member w visibles) $ dzenWithArgs (show name ++ " requests your attention on workspace " ++ index) args duration - -dzenWithArgs :: String -> [String] -> Int -> X () -dzenWithArgs str args timeout = io $ runProcessWithInputAndWait "dzen2" args (unchomp str) timeout - -- dzen seems to require the input to terminate with exactly one newline. - where unchomp s@['\n'] = s - unchomp [] = ['\n'] - unchomp (c:cs) = c : unchomp cs -- cgit v1.2.3