diff options
| author | Andrea Rossato <andrea.rossato@ing.unitn.it> | 2007-06-26 10:06:19 +0200 | 
|---|---|---|
| committer | Andrea Rossato <andrea.rossato@ing.unitn.it> | 2007-06-26 10:06:19 +0200 | 
| commit | 0cef0a9fded62e1d425124fd28db06f869d7f308 (patch) | |
| tree | 9f266ef779e106f982911f9bbb32798030049150 | |
| parent | 877c1f675d58443a839783f5897b7e164a351c0d (diff) | |
| download | xmobar-0cef0a9fded62e1d425124fd28db06f869d7f308.tar.gz xmobar-0cef0a9fded62e1d425124fd28db06f869d7f308.tar.bz2 | |
added refresh rate config option for each command to be run
darcs-hash:20070626080619-d6583-2d486498682a2f4e59c66effbfeb6861c609aef5.gz
| -rw-r--r-- | xmobar.config-sample | 2 | ||||
| -rw-r--r-- | xmobar.hs | 24 | 
2 files changed, 18 insertions, 8 deletions
| diff --git a/xmobar.config-sample b/xmobar.config-sample index 108e870..ad333bc 100644 --- a/xmobar.config-sample +++ b/xmobar.config-sample @@ -7,7 +7,7 @@ Config { fonts = "-misc-fixed-*-*-*-*-10-*-*-*-*-*-*-*"         , hight = 15         , align = "right"         , refresh = 10 -       , commands = [("xmb-net", ["eth1"])] +       , commands = [("xmb-net", 10, ["eth1"])]         , sepChar = "%"         , template = "%xmb-cpu% %xmb-mem% %xmb-net% <fc=#ee9a00>%date%</fc>"         } @@ -79,7 +79,8 @@ data Config =             , hight          :: Int      -- ^ Window hight             , align          :: String   -- ^ text alignment             , refresh        :: Int      -- ^ Refresh rate in tenth of seconds -           , commands       :: [(String,[String])]   -- ^ For setting the options of the programs to run (optionals) +           , commands       :: [(String, Int, [String])]   -- ^ For setting the refresh rate and  +                                                           -- options for the programs to run (optionals)             , sepChar        :: String     -- ^ The character to be used for indicating                                           --   commands in the output template (default '%')             , template       :: String   -- ^ The output template  @@ -96,7 +97,7 @@ defaultConfig =             , hight = 15             , align = "left"             , refresh = 10 -           , commands = [] +           , commands = [("date", 100, [])]             , sepChar = "%"             , template = "Uptime: <fc=#00FF00>%uptime%</fc> ** <fc=#FF0000>%date%</fc>"             } @@ -207,11 +208,20 @@ printStrings config dpy win gc fontst offs sl@((s,c,l):xs) =  getOptions :: Config -> String -> [String]  getOptions c com =      let l = commands c -        p = filter (\(s,_) -> s == com) l +        p = filter (\(s,_,_) -> s == com) l      in case p of -         [(_,opts)] -> opts +         [(_,_,opts)] -> opts           _ -> [] +-- | Gets the command options set in configuration. +getRefRate :: Config -> String -> Int +getRefRate c com = +    let l = commands c +        p = filter (\(s,_,_) -> s == com) l +    in case p of +         [(_,int,_)] -> int +         _ -> refresh c +  -- | Runs a list of programs  execCommands :: Config -> [(String,String,String)] -> IO [(ThreadId, MVar String)]  execCommands _ [] = return [] @@ -245,18 +255,18 @@ runCommandLoop var conf c@(s,com,ss)               ExitSuccess -> do str <- hGetLine o                                 closeHandles                                 modifyMVar_ var (\_ -> return $ s ++ str ++ ss) -                               threadDelay $ 100000 * refresh conf +                               threadDelay $ 100000 * (getRefRate conf com)                                 runCommandLoop var conf c               _ -> do closeHandles                       modifyMVar_ var $ \_ -> return $ "Could not execute command " ++ com -                     threadDelay $ 100000 * refresh conf +                     threadDelay $ 100000 * (getRefRate conf com)                       runCommandLoop var conf c  -- | Reads MVars set by 'runCommandLoop'  readVariables :: [(ThreadId, MVar String)] -> IO String  readVariables [] = return "" -readVariables ((h,v):xs) = +readVariables ((_,v):xs) =      do f <- readMVar v         fs <- readVariables xs         return $! f ++ fs | 
