diff options
author | Jose A. Ortega Ruiz <jao@gnu.org> | 2010-01-19 03:17:53 +0100 |
---|---|---|
committer | Jose A. Ortega Ruiz <jao@gnu.org> | 2010-01-19 03:17:53 +0100 |
commit | 3d100946bc6f900fb5a4035213f4c8c1fd81f062 (patch) | |
tree | 980a5df2503bebddf45888ef07fa98cc0904c536 /Plugins | |
parent | 583e88ca4f36938942e982ed1d2f45dd1ea01446 (diff) | |
download | xmobar-3d100946bc6f900fb5a4035213f4c8c1fd81f062.tar.gz xmobar-3d100946bc6f900fb5a4035213f4c8c1fd81f062.tar.bz2 |
Tiny refactoring
Ignore-this: 404b0000887a9c4dfc5209a9f647d561
darcs-hash:20100119021753-40885-3dd49b3e05ab638a27f51f79e1ee0ad34563f001.gz
Diffstat (limited to 'Plugins')
-rw-r--r-- | Plugins/Monitors/MultiCpu.hs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Plugins/Monitors/MultiCpu.hs b/Plugins/Monitors/MultiCpu.hs index 39e48c8..43283a8 100644 --- a/Plugins/Monitors/MultiCpu.hs +++ b/Plugins/Monitors/MultiCpu.hs @@ -41,26 +41,26 @@ parseCpuData = do (as, bs) <- doActionTwiceWithDelay 950000 cpuData let p0 = zipWith percent bs as return p0 - -- (as', bs') <- doActionTwiceWithDelay 350000 cpuData - -- let p1 = zipWith percent bs' as' - -- return $ zipWith (\x y -> zipWith (\a b -> (a + b) / 2.0) x y) p1 p0 percent :: [Float] -> [Float] -> [Float] percent b a = if tot > 0 then map (/ tot) $ take 4 dif else [0, 0, 0, 0] where dif = zipWith (-) b a tot = foldr (+) 0 dif +emptyPercs :: [String] +emptyPercs = repeat " 0%" + formatMultiCpus :: [[Float]] -> Monitor [String] -formatMultiCpus [] = return $ take 15 (repeat " 0%") +formatMultiCpus [] = return $ take 15 emptyPercs formatMultiCpus xs = fmap concat $ mapM formatCpu xs formatCpu :: [Float] -> Monitor [String] formatCpu x - | length x < 4 = return $ take 5 (repeat "") + | length x < 4 = return $ take 5 emptyPercs | otherwise = mapM (showWithColors f) . map (* 100) $ (t:x) where f s = pad $ floatToPercent (s / 100) t = foldr (+) 0 $ take 3 x - pad s = take (4 - length s) (repeat ' ') ++ s + pad s = take (4 - length s) " " ++ s runMultiCpu :: [String] -> Monitor String runMultiCpu _ = |