diff options
author | glasser <glasser@mit.edu> | 2007-05-23 20:43:15 +0200 |
---|---|---|
committer | glasser <glasser@mit.edu> | 2007-05-23 20:43:15 +0200 |
commit | 3c0b22f9799a4c607df473ebc77d82dd218527de (patch) | |
tree | 34c3d3fa86d7712948a13c8c6c62b764a965270c | |
parent | bea0345abfee66e10b0b5444f139ea8ac59690e0 (diff) | |
download | XMonadContrib-3c0b22f9799a4c607df473ebc77d82dd218527de.tar.gz XMonadContrib-3c0b22f9799a4c607df473ebc77d82dd218527de.tar.xz XMonadContrib-3c0b22f9799a4c607df473ebc77d82dd218527de.zip |
dzen module (with xinerama support, which requires glasser's Xinerama patch to dzen)
darcs-hash:20070523184315-64353-2f7d112bfab370c3b02397317a8dbe8686bc10be.gz
-rw-r--r-- | Dzen.hs | 49 |
1 files changed, 49 insertions, 0 deletions
@@ -0,0 +1,49 @@ +module XMonadContrib.Dzen (dzen, dzenScreen) where + +import System.Posix.Process (forkProcess, getProcessStatus, createSession) +import System.IO +import System.Process +import System.Exit +import Control.Concurrent (threadDelay) +import Control.Monad.State + +import qualified StackSet as W +import XMonad + +-- wait is in us +runProcessWithInputAndWait :: FilePath -> [String] -> String -> Int -> IO () +runProcessWithInputAndWait cmd args input timeout = do + pid <- forkProcess $ do + forkProcess $ do -- double fork it over to init + createSession + (pin, pout, perr, ph) <- runInteractiveProcess cmd args Nothing Nothing + hPutStr pin input + hFlush pin + threadDelay timeout + hClose pin + -- output <- hGetContents pout + -- when (output==output) $ return () + hClose pout + hClose perr + waitForProcess ph + return () + exitWith ExitSuccess + return () + getProcessStatus True False pid + return () + + +curScreen :: X ScreenId +curScreen = (W.screen . W.current) `liftM` gets windowset + +toXineramaArg :: ScreenId -> String +toXineramaArg n = show ( ((fromIntegral n)+1)::Int ) + +-- requires glasser's xinerama patch to dzen + +dzen :: String -> X () +dzen str = curScreen >>= \sc -> dzenScreen sc str + +dzenScreen :: ScreenId -> String -> X() +dzenScreen sc str = io $ (runProcessWithInputAndWait "dzen2" ["-xs", screen] str 5000000) + where screen = toXineramaArg sc |