From 2d6911f940ec82c2054cf96b151ac9ff61372865 Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Tue, 19 Jan 2010 23:23:47 +0100 Subject: MultiCpus: hlinting Ignore-this: 3052c410453447cc9ff89950df4c0077 darcs-hash:20100119222347-40885-94bf85e137995f47d59af199c08b8c243aa297a6.gz --- Plugins/Monitors/MultiCpu.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Plugins') diff --git a/Plugins/Monitors/MultiCpu.hs b/Plugins/Monitors/MultiCpu.hs index 43283a8..1c89a76 100644 --- a/Plugins/Monitors/MultiCpu.hs +++ b/Plugins/Monitors/MultiCpu.hs @@ -21,7 +21,7 @@ import Data.List(isPrefixOf) multiCpuConfig :: IO MConfig multiCpuConfig = mkMConfig "Cpu: " - [ k ++ n | n <- "":(map show [0 :: Int ..]) + [ k ++ n | n <- "" : map show [0 :: Int ..] , k <- ["total","user","nice","system","idle"]] @@ -32,7 +32,7 @@ cpuData = do s <- B.readFile "/proc/stat" cpuParser :: B.ByteString -> [[Float]] cpuParser = map parseList . cpuLists where cpuLists = takeWhile isCpu . map B.words . B.lines - isCpu (w:_) = "cpu" `isPrefixOf` (B.unpack w) + isCpu (w:_) = "cpu" `isPrefixOf` B.unpack w isCpu _ = False parseList = map (read . B.unpack) . tail @@ -57,13 +57,13 @@ formatMultiCpus xs = fmap concat $ mapM formatCpu xs formatCpu :: [Float] -> Monitor [String] formatCpu x | length x < 4 = return $ take 5 emptyPercs - | otherwise = mapM (showWithColors f) . map (* 100) $ (t:x) - where f s = pad $ floatToPercent (s / 100) + | otherwise = mapM (showWithColors f . (* 100)) (t:x) + where f = pad . floatToPercent . (/ 100) t = foldr (+) 0 $ take 3 x pad s = take (4 - length s) " " ++ s runMultiCpu :: [String] -> Monitor String runMultiCpu _ = - do c <- io $ parseCpuData + do c <- io parseCpuData l <- formatMultiCpus c parseTemplate l -- cgit v1.2.3