diff options
author | Andrea Rossato <andrea.rossato@ing.unitn.it> | 2007-07-24 11:44:35 +0200 |
---|---|---|
committer | Andrea Rossato <andrea.rossato@ing.unitn.it> | 2007-07-24 11:44:35 +0200 |
commit | 9928c4c9ea1648c0735b1219e15f00307cacfa0d (patch) | |
tree | ba75b30bce11b756bbe68890e0dc7e13f231e39b /Commands.hs | |
parent | 1209c4f6bb3218cacdfbd7337488abf4bcb05245 (diff) | |
download | xmobar-9928c4c9ea1648c0735b1219e15f00307cacfa0d.tar.gz xmobar-9928c4c9ea1648c0735b1219e15f00307cacfa0d.tar.bz2 |
code and output cleanup
darcs-hash:20070724094435-d6583-dec41cb61e2f547ae45835873aadcbb0fc21dd8e.gz
Diffstat (limited to 'Commands.hs')
-rw-r--r-- | Commands.hs | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/Commands.hs b/Commands.hs index cb87521..6b8dcbd 100644 --- a/Commands.hs +++ b/Commands.hs @@ -13,8 +13,7 @@ -- The 'Exec' class rappresents the executable types, whose constructors may -- appear in the 'Config.commands' field of the 'Config.Config' data type. -- --- The 'Command' data type stores the monitors to be run internally by --- Xmobar. +-- The 'Command' data type is for OS commands to be run by Xmobar -- ----------------------------------------------------------------------------- @@ -41,16 +40,17 @@ instance Exec Command where alias (Com p _ a _) | p /= "" = if a == "" then p else a | otherwise = "" rate (Com _ _ _ r) = r - run (Com prog args _ _) = do (i,o,e,p) <- runInteractiveCommand (prog ++ concat (map (' ':) args)) - exit <- waitForProcess p - let closeHandles = do hClose o - hClose i - hClose e - case exit of - ExitSuccess -> do str <- hGetLine o - closeHandles - return str - _ -> do closeHandles - return $ "Could not execute command " ++ prog - - + run (Com prog args _ _) = do + (i,o,e,p) <- runInteractiveCommand (prog ++ concat (map (' ':) args)) + exit <- waitForProcess p + let closeHandles = do + hClose o + hClose i + hClose e + case exit of + ExitSuccess -> do + str <- hGetLine o + closeHandles + return str + _ -> do closeHandles + return $ "Could not execute command " ++ prog |