diff options
author | Andrea Rossato <andrea.rossato@ing.unitn.it> | 2007-07-11 18:50:35 +0200 |
---|---|---|
committer | Andrea Rossato <andrea.rossato@ing.unitn.it> | 2007-07-11 18:50:35 +0200 |
commit | df36230da4d10d32758736d30eab0fd2073f0578 (patch) | |
tree | 490f0c447afc6a3c5b157dd012460fb3866fd358 /Monitors/Common.hs | |
parent | 3fff39ac86711de214bbe8a7947296eca2b3fbfb (diff) | |
download | xmobar-df36230da4d10d32758736d30eab0fd2073f0578.tar.gz xmobar-df36230da4d10d32758736d30eab0fd2073f0578.tar.bz2 |
removed from monitors code not used anymore
darcs-hash:20070711165035-d6583-e556a6910bf8deb91677a5d590eb45f157a400d7.gz
Diffstat (limited to 'Monitors/Common.hs')
-rw-r--r-- | Monitors/Common.hs | 51 |
1 files changed, 19 insertions, 32 deletions
diff --git a/Monitors/Common.hs b/Monitors/Common.hs index 306d46f..616c8bd 100644 --- a/Monitors/Common.hs +++ b/Monitors/Common.hs @@ -59,7 +59,6 @@ import Text.ParserCombinators.Parsec import System.Console.GetOpt import System.Environment -import System.Exit -- $monitor @@ -72,9 +71,9 @@ data MConfig = , high :: IORef Int , highColor :: IORef (Maybe String) , template :: IORef String - , packageName :: IORef String - , usageTail :: IORef String - , addedArgs :: IORef [OptDescr Opts] +-- , packageName :: IORef String +-- , usageTail :: IORef String +-- , addedArgs :: IORef [OptDescr Opts] , export :: IORef [String] } @@ -100,62 +99,54 @@ getConfigValue s = sel s mkMConfig :: String - -> String - -> String - -> [OptDescr Opts] -> [String] -> IO MConfig -mkMConfig tmpl pkg usg args exprts = +mkMConfig tmpl exprts = do lc <- newIORef Nothing l <- newIORef 33 nc <- newIORef Nothing h <- newIORef 66 hc <- newIORef Nothing t <- newIORef tmpl - p <- newIORef pkg - u <- newIORef usg - a <- newIORef args +-- p <- newIORef pkg +-- u <- newIORef usg +-- a <- newIORef args e <- newIORef exprts - return $ MC nc l lc h hc t p u a e + return $ MC nc l lc h hc t e +-- return $ MC nc l lc h hc t p u a e -data Opts = Help - | Version - | HighColor String +data Opts = HighColor String | NormalColor String | LowColor String | Low String | High String | Template String - | Others String options :: Monitor [OptDescr Opts] options = do t <- getConfigValue export - ao <- getConfigValue addedArgs tmpl <- getConfigValue template - return $ [ Option ['h'] ["help"] (NoArg Help) "Show this help" - , Option ['V'] ["version"] (NoArg Version) "Show version information" - , Option ['H'] ["High"] (ReqArg High "number") "The high threshold" + return $ [ Option ['H'] ["High"] (ReqArg High "number") "The high threshold" , Option ['L'] ["Low"] (ReqArg Low "number") "The low threshold" - , Option [] ["high"] (ReqArg HighColor "color number") "Color for the high threshold: ex \"#FF0000\"" - , Option [] ["normal"] (ReqArg NormalColor "color number") "Color for the normal threshold: ex \"#00FF00\"" - , Option [] ["low"] (ReqArg LowColor "color number") "Color for the low threshold: ex \"#0000FF\"" + , Option ['h'] ["high"] (ReqArg HighColor "color number") "Color for the high threshold: ex \"#FF0000\"" + , Option ['n'] ["normal"] (ReqArg NormalColor "color number") "Color for the normal threshold: ex \"#00FF00\"" + , Option ['l'] ["low"] (ReqArg LowColor "color number") "Color for the low threshold: ex \"#0000FF\"" , Option ['t'] ["template"] (ReqArg Template "output template") ("Output template.\nAvaliable variables: " ++ show t ++ "\nDefault template: " ++ show tmpl) - ] ++ ao - + ] +{- usage :: Monitor () usage = do pn <- io $ getProgName - u <- getConfigValue usageTail opts <- options - io $ putStr $ usageInfo ("Usage: " ++ pn ++ " [OPTIONS...] " ++ u) opts + io $ putStr $ usageInfo ("Usage: " ++ pn ++ " [OPTIONS...] ") opts version :: String version = "0.5" versinfo :: String -> String -> IO () versinfo p v = putStrLn $ p ++" " ++ v +-} doArgs :: [String] -> Monitor String @@ -174,18 +165,14 @@ doArgs args actionFail action = doConfigOptions :: [Opts] -> Monitor () doConfigOptions [] = io $ return () doConfigOptions (o:oo) = - do pn <- getConfigValue packageName - let next = doConfigOptions oo + do let next = doConfigOptions oo case o of - Help -> usage >> io (exitWith ExitSuccess) - Version -> io $ versinfo pn version >> exitWith ExitSuccess High h -> setConfigValue (read h) high >> next Low l -> setConfigValue (read l) low >> next HighColor hc -> setConfigValue (Just hc) highColor >> next NormalColor nc -> setConfigValue (Just nc) normalColor >> next LowColor lc -> setConfigValue (Just lc) lowColor >> next Template t -> setConfigValue t template >> next - _ -> next runMonitor :: IO MConfig -> Monitor String -> ([String] -> Monitor String) -> IO () runMonitor conf actionFail action = |