mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-05-19 11:30:22 -07:00
add haddock for top-level Dzen bindings
This commit is contained in:
parent
fd268ab7b9
commit
83cc45d972
24
Dzen.hs
24
Dzen.hs
@ -27,20 +27,28 @@ import XMonad
|
|||||||
import XMonadContrib.NamedWindows (getName)
|
import XMonadContrib.NamedWindows (getName)
|
||||||
import XMonadContrib.Run (runProcessWithInputAndWait, seconds)
|
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.
|
-- | @dzen str timeout@ pipes @str@ to dzen2 for @timeout@ microseconds.
|
||||||
-- Example usage:
|
-- Example usage:
|
||||||
-- > dzen "Hi, mom!" (5 `seconds`)
|
-- > dzen "Hi, mom!" (5 `seconds`)
|
||||||
dzen :: String -> Int -> X ()
|
dzen :: String -> Int -> X ()
|
||||||
dzen str timeout = dzenWithArgs str [] timeout
|
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@.
|
-- | @dzenScreen sc str timeout@ pipes @str@ to dzen2 for @timeout@ microseconds, and on screen @sc@.
|
||||||
-- Requires dzen to be compiled with Xinerama support.
|
-- Requires dzen to be compiled with Xinerama support.
|
||||||
dzenScreen :: ScreenId -> String -> Int -> X()
|
dzenScreen :: ScreenId -> String -> Int -> X()
|
||||||
dzenScreen sc str timeout = dzenWithArgs str ["-xs", screen] timeout
|
dzenScreen sc str timeout = dzenWithArgs str ["-xs", screen] timeout
|
||||||
where screen = toXineramaArg sc
|
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
|
-- | Flashes when a window requests your attention and you can't see it. For use with
|
||||||
-- XMonadContrib.UrgencyHook. Usage:
|
-- XMonadContrib.UrgencyHook. Usage:
|
||||||
@ -48,6 +56,9 @@ dzenScreen sc str timeout = dzenWithArgs str ["-xs", screen] timeout
|
|||||||
dzenUrgencyHook :: Int -> Window -> X ()
|
dzenUrgencyHook :: Int -> Window -> X ()
|
||||||
dzenUrgencyHook = dzenUrgencyHookWithArgs []
|
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 :: [String] -> Int -> Window -> X ()
|
||||||
dzenUrgencyHookWithArgs args duration w = do
|
dzenUrgencyHookWithArgs args duration w = do
|
||||||
visibles <- gets mapped
|
visibles <- gets mapped
|
||||||
@ -58,10 +69,3 @@ dzenUrgencyHookWithArgs args duration w = do
|
|||||||
when (not $ S.member w visibles) $
|
when (not $ S.member w visibles) $
|
||||||
dzenWithArgs (show name ++ " requests your attention on workspace " ++ index)
|
dzenWithArgs (show name ++ " requests your attention on workspace " ++ index)
|
||||||
args duration
|
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
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user