From a615474dc2daa250602262d59bd3daa7d603cc12 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Wed, 8 Dec 2010 01:38:14 +0100 Subject: Default to False for the -P option and leave the % to the templates --- Plugins/Monitors/Batt.hs | 2 +- Plugins/Monitors/Common.hs | 9 +++++---- Plugins/Monitors/Cpu.hs | 8 ++++---- Plugins/Monitors/Mem.hs | 2 +- Plugins/Monitors/MultiCpu.hs | 2 +- Plugins/Monitors/Swap.hs | 2 +- 6 files changed, 13 insertions(+), 12 deletions(-) (limited to 'Plugins') diff --git a/Plugins/Monitors/Batt.hs b/Plugins/Monitors/Batt.hs index 16af6da..547dd02 100644 --- a/Plugins/Monitors/Batt.hs +++ b/Plugins/Monitors/Batt.hs @@ -23,7 +23,7 @@ data Batt = Batt Float String battConfig :: IO MConfig battConfig = mkMConfig - "Batt: " -- template + "Batt: %" -- template ["leftbar", "left", "status"] -- available replacements type File = (String, String) diff --git a/Plugins/Monitors/Common.hs b/Plugins/Monitors/Common.hs index 637dbd9..9f1db3c 100644 --- a/Plugins/Monitors/Common.hs +++ b/Plugins/Monitors/Common.hs @@ -130,7 +130,7 @@ mkMConfig tmpl exprts = bb <- newIORef ":" bf <- newIORef "#" bw <- newIORef 10 - up <- newIORef True + up <- newIORef False return $ MC nc l lc h hc t e p mn mx pc pr bb bf bw up data Opts = HighColor String @@ -184,7 +184,7 @@ doConfigOptions [] = io $ return () doConfigOptions (o:oo) = do let next = doConfigOptions oo nz s = let x = read s in max 0 x - bool s = s == "True" + bool = (`elem` ["True", "true", "Yes", "yes", "On", "on"]) case o of High h -> setConfigValue (read h) high >> next Low l -> setConfigValue (read l) low >> next @@ -198,13 +198,14 @@ doConfigOptions (o:oo) = Width w -> setConfigValue (nz w) minWidth >> setConfigValue (nz w) maxWidth >> next PadChars pc -> setConfigValue pc padChars >> next - PadAlign pa -> setConfigValue (isPrefixOf "r" pa) padRight >> next + PadAlign a -> setConfigValue ("r" `isPrefixOf` a) padRight >> next BarBack bb -> setConfigValue bb barBack >> next BarFore bf -> setConfigValue bf barFore >> next BarWidth bw -> setConfigValue (nz bw) barWidth >> next UsePercent up -> setConfigValue (bool up) usePercent >> next -runM :: [String] -> IO MConfig -> ([String] -> Monitor String) -> Int -> (String -> IO ()) -> IO () +runM :: [String] -> IO MConfig -> ([String] -> Monitor String) -> Int + -> (String -> IO ()) -> IO () runM args conf action r cb = go where go = do c <- conf diff --git a/Plugins/Monitors/Cpu.hs b/Plugins/Monitors/Cpu.hs index d94bd0f..78e3ec7 100644 --- a/Plugins/Monitors/Cpu.hs +++ b/Plugins/Monitors/Cpu.hs @@ -19,8 +19,8 @@ import qualified Data.ByteString.Lazy.Char8 as B cpuConfig :: IO MConfig cpuConfig = mkMConfig - "Cpu: " -- template - ["bar","total","user","nice","system","idle"] -- available replacements + "Cpu: %" + ["bar","total","user","nice","system","idle"] cpuData :: IO [Float] cpuData = do s <- B.readFile "/proc/stat" @@ -28,7 +28,7 @@ cpuData = do s <- B.readFile "/proc/stat" cpuParser :: B.ByteString -> [Float] cpuParser = - map read . map B.unpack . tail . B.words . flip (!!) 0 . B.lines + map (read . B.unpack) . tail . B.words . flip (!!) 0 . B.lines parseCPU :: IO [Float] parseCPU = @@ -48,6 +48,6 @@ formatCpu xs = do runCpu :: [String] -> Monitor String runCpu _ = - do c <- io $ parseCPU + do c <- io parseCPU l <- formatCpu c parseTemplate l diff --git a/Plugins/Monitors/Mem.hs b/Plugins/Monitors/Mem.hs index e1ea5de..a55d58e 100644 --- a/Plugins/Monitors/Mem.hs +++ b/Plugins/Monitors/Mem.hs @@ -18,7 +18,7 @@ import Plugins.Monitors.Common memConfig :: IO MConfig memConfig = mkMConfig - "Mem: (M)" -- template + "Mem: % (M)" -- template ["usedbar", "freebar", "usedratio", "total", "free", "buffer", "cache", "rest", "used"] -- available replacements diff --git a/Plugins/Monitors/MultiCpu.hs b/Plugins/Monitors/MultiCpu.hs index 223ff24..069199b 100644 --- a/Plugins/Monitors/MultiCpu.hs +++ b/Plugins/Monitors/MultiCpu.hs @@ -20,7 +20,7 @@ import Data.List (isPrefixOf) multiCpuConfig :: IO MConfig multiCpuConfig = - mkMConfig "Cpu: " + mkMConfig "Cpu: %" [ k ++ n | n <- "" : map show [0 :: Int ..] , k <- ["bar","total","user","nice","system","idle"]] diff --git a/Plugins/Monitors/Swap.hs b/Plugins/Monitors/Swap.hs index 8901a2a..d2e6077 100644 --- a/Plugins/Monitors/Swap.hs +++ b/Plugins/Monitors/Swap.hs @@ -20,7 +20,7 @@ import qualified Data.ByteString.Lazy.Char8 as B swapConfig :: IO MConfig swapConfig = mkMConfig - "Swap: " -- template + "Swap: %" -- template ["usedratio", "total", "used", "free"] -- available replacements fileMEM :: IO B.ByteString -- cgit v1.2.3