summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2010-12-22 00:39:42 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2010-12-22 00:39:42 +0100
commitfac7217f853cb8ea7724cda58adef13a385f3770 (patch)
tree54e19e02371e6bf2702e640d1e7543df55346f76 /src
parentc50207a47e1d6a42d2d71bc5ca0468162673036b (diff)
downloadxmobar-fac7217f853cb8ea7724cda58adef13a385f3770.tar.gz
xmobar-fac7217f853cb8ea7724cda58adef13a385f3770.tar.bz2
MultiCpu linting
Diffstat (limited to 'src')
-rw-r--r--src/Plugins/Monitors/MultiCpu.hs23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/Plugins/Monitors/MultiCpu.hs b/src/Plugins/Monitors/MultiCpu.hs
index b8c71ca..d93c788 100644
--- a/src/Plugins/Monitors/MultiCpu.hs
+++ b/src/Plugins/Monitors/MultiCpu.hs
@@ -21,22 +21,19 @@ import Data.List (isPrefixOf, transpose, unfoldr)
multiCpuConfig :: IO MConfig
multiCpuConfig =
mkMConfig "Cpu: <total>%" $
- map ("auto" ++) monitors
- ++ [ k ++ n | n <- "" : map show [0 :: Int ..]
- , k <- monitors]
+ ["auto" ++ k | k <- monitors] ++
+ [ k ++ n | n <- "" : map show [0 :: Int ..]
+ , k <- monitors]
where monitors = ["bar","total","user","nice","system","idle"]
cpuData :: IO [[Float]]
-cpuData = do s <- B.readFile "/proc/stat"
- return $ cpuParser s
-
-cpuParser :: B.ByteString -> [[Float]]
-cpuParser = map parseList . cpuLists
- where cpuLists = takeWhile isCpu . map B.words . B.lines
+cpuData = parse `fmap` B.readFile "/proc/stat"
+ where parse = map parseList . cpuLists
+ cpuLists = takeWhile isCpu . map B.words . B.lines
isCpu (w:_) = "cpu" `isPrefixOf` B.unpack w
isCpu _ = False
- parseList = map (read . B.unpack) . tail
+ parseList = map (parseFloat . B.unpack) . tail
parseCpuData :: IO [[Float]]
parseCpuData =
@@ -62,9 +59,7 @@ formatCpu xs
return (b:ps)
splitEvery :: (Eq a) => Int -> [a] -> [[a]]
-splitEvery n = unfoldr (\x -> if x == []
- then Nothing
- else Just $ splitAt n x)
+splitEvery n = unfoldr (\x -> if null x then Nothing else Just $ splitAt n x)
groupData :: [String] -> [[String]]
groupData = transpose . tail . splitEvery 6
@@ -78,4 +73,4 @@ runMultiCpu _ =
do c <- io parseCpuData
l <- formatMultiCpus c
a <- formatAutoCpus l
- parseTemplate (a ++ l)
+ parseTemplate $ a ++ l