diff options
author | Devin Mullins <me@twifkak.com> | 2007-10-18 03:29:10 +0200 |
---|---|---|
committer | Devin Mullins <me@twifkak.com> | 2007-10-18 03:29:10 +0200 |
commit | d8d003eb6621245e59430ecfd5de27dcd6bcccda (patch) | |
tree | a3773cf297a2d192a0abec3b2f05503a122b255f /Dzen.hs | |
parent | 54507995ebec87397635f8033c483d5ed07e6f8e (diff) | |
download | XMonadContrib-d8d003eb6621245e59430ecfd5de27dcd6bcccda.tar.gz XMonadContrib-d8d003eb6621245e59430ecfd5de27dcd6bcccda.tar.xz XMonadContrib-d8d003eb6621245e59430ecfd5de27dcd6bcccda.zip |
fixed Dzen and gave it a configurable timeout
darcs-hash:20071018012910-78224-804cedb28d826ddfc3d1a8177aa8460b38fe6591.gz
Diffstat (limited to 'Dzen.hs')
-rw-r--r-- | Dzen.hs | 33 |
1 files changed, 19 insertions, 14 deletions
@@ -8,28 +8,33 @@ -- Stability : unstable -- Portability : unportable -- --- Handy wrapper for dzen. +-- Handy wrapper for dzen. Requires dzen >= 0.2.4. -- ----------------------------------------------------------------------------- -module XMonadContrib.Dzen (dzen, dzenScreen) where +module XMonadContrib.Dzen (dzen, dzenScreen, seconds) where -import Control.Monad.State -import qualified StackSet as W import XMonad -import XMonadContrib.Run - -curScreen :: X ScreenId -curScreen = (W.screen . W.current) `liftM` gets windowset +import XMonadContrib.Run (runProcessWithInputAndWait, seconds) toXineramaArg :: ScreenId -> String toXineramaArg n = show ( ((fromIntegral n)+1)::Int ) --- Requires dzen >= 0.2.4. +-- | @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 :: String -> X () -dzen str = curScreen >>= \sc -> dzenScreen sc str +-- | @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 -dzenScreen :: ScreenId -> String -> X() -dzenScreen sc str = io $ (runProcessWithInputAndWait "dzen2" ["-xs", screen] str 5000000) - where screen = toXineramaArg sc +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 |