From df36230da4d10d32758736d30eab0fd2073f0578 Mon Sep 17 00:00:00 2001 From: Andrea Rossato Date: Wed, 11 Jul 2007 18:50:35 +0200 Subject: removed from monitors code not used anymore darcs-hash:20070711165035-d6583-e556a6910bf8deb91677a5d590eb45f157a400d7.gz --- Monitors/Batt.hs | 13 ------------- Monitors/Common.hs | 51 +++++++++++++++++++-------------------------------- Monitors/Cpu.hs | 13 ------------- Monitors/Mem.hs | 13 ------------- Monitors/Swap.hs | 13 ------------- Monitors/Weather.hs | 3 --- 6 files changed, 19 insertions(+), 87 deletions(-) diff --git a/Monitors/Batt.hs b/Monitors/Batt.hs index df288d8..2a81e12 100644 --- a/Monitors/Batt.hs +++ b/Monitors/Batt.hs @@ -22,9 +22,6 @@ import Monitors.Common battConfig :: IO MConfig battConfig = mkMConfig "Batt: " -- template - package -- package - "" -- usage tail? - [] -- added args ["left"] -- available replacements fileB1 :: (String, String) @@ -63,18 +60,8 @@ formatBatt x = l <- showWithColors f (x * 100) return [l] -package :: String -package = "xmb-batt" - runBatt :: [String] -> Monitor String runBatt _ = do c <- io $ parseBATT l <- formatBatt c parseTemplate l - -{- -main :: IO () -main = - do let af = runBatt [] - runMonitor battConfig af runBatt --} 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 = diff --git a/Monitors/Cpu.hs b/Monitors/Cpu.hs index 456add0..b3a125d 100644 --- a/Monitors/Cpu.hs +++ b/Monitors/Cpu.hs @@ -20,9 +20,6 @@ import qualified Data.ByteString.Lazy.Char8 as B cpuConfig :: IO MConfig cpuConfig = mkMConfig "Cpu: " -- template - package -- package - "" -- usage tail? - [] -- added args ["total","user","nice","system","idle"] -- available replacements cpuData :: IO [Float] @@ -49,18 +46,8 @@ formatCpu x = list = t:x mapM (showWithColors f) . map (* 100) $ list -package :: String -package = "xmb-cpu" - runCpu :: [String] -> Monitor String runCpu _ = do c <- io $ parseCPU l <- formatCpu c parseTemplate l - -{- -main :: IO () -main = - do let af = runCpu [] - runMonitor cpuConfig af runCpu --} diff --git a/Monitors/Mem.hs b/Monitors/Mem.hs index b65715d..dd132a7 100644 --- a/Monitors/Mem.hs +++ b/Monitors/Mem.hs @@ -19,9 +19,6 @@ import Monitors.Common memConfig :: IO MConfig memConfig = mkMConfig "Mem: % (M)" -- template - package -- package - "" -- usage tail? - [] -- added args ["total", "free", "buffer", -- available replacements "cache", "rest", "used", "usedratio"] @@ -43,18 +40,8 @@ formatMem x = do let f n = show (takeDigits 2 n) mapM (showWithColors f) x -package :: String -package = "xmb-mem" - runMem :: [String] -> Monitor String runMem _ = do m <- io $ parseMEM l <- formatMem m parseTemplate l - -{- -main :: IO () -main = - do let af = runMem [] - runMonitor monitorConfig af runMem --} diff --git a/Monitors/Swap.hs b/Monitors/Swap.hs index e83b1e0..a2091e8 100644 --- a/Monitors/Swap.hs +++ b/Monitors/Swap.hs @@ -21,9 +21,6 @@ import qualified Data.ByteString.Lazy.Char8 as B swapConfig :: IO MConfig swapConfig = mkMConfig "Swap: " -- template - package -- package - "" -- usage tail? - [] -- added args ["total", "used", "free", "usedratio"] -- available replacements fileMEM :: IO B.ByteString @@ -46,18 +43,8 @@ formatSwap x = lasts <- mapM (showWithColors f2) tl return $ firsts ++ lasts -package :: String -package = "xmb-swap" - runSwap :: [String] -> Monitor String runSwap _ = do m <- io $ parseMEM l <- formatSwap m parseTemplate l - -{- -main :: IO () -main = - do let af = runSwap [] - runMonitor swapConfig af runSwap --} diff --git a/Monitors/Weather.hs b/Monitors/Weather.hs index 8b3172e..1647ae5 100644 --- a/Monitors/Weather.hs +++ b/Monitors/Weather.hs @@ -26,9 +26,6 @@ import Text.ParserCombinators.Parsec weatherConfig :: IO MConfig weatherConfig = mkMConfig ": C, rh % ()" -- template - package -- package - "station ID" -- usage tail? - [] -- added args ["station" -- available replacements , "stationState" , "year" -- cgit v1.2.3