From 9928c4c9ea1648c0735b1219e15f00307cacfa0d Mon Sep 17 00:00:00 2001 From: Andrea Rossato Date: Tue, 24 Jul 2007 11:44:35 +0200 Subject: code and output cleanup darcs-hash:20070724094435-d6583-dec41cb61e2f547ae45835873aadcbb0fc21dd8e.gz --- Commands.hs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'Commands.hs') 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 -- cgit v1.2.3