From 583e88ca4f36938942e982ed1d2f45dd1ea01446 Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Tue, 19 Jan 2010 03:02:44 +0100 Subject: MultiCpus: pad percentages Ignore-this: 6b8133d37a7ed40ae8b3dbc4d31920fa darcs-hash:20100119020244-40885-c5d0ea1ba9725b8696d254da5e91d1071e483035.gz --- Plugins/Monitors/MultiCpu.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugins/Monitors/MultiCpu.hs b/Plugins/Monitors/MultiCpu.hs index 6bbcdd3..39e48c8 100644 --- a/Plugins/Monitors/MultiCpu.hs +++ b/Plugins/Monitors/MultiCpu.hs @@ -51,15 +51,16 @@ percent b a = if tot > 0 then map (/ tot) $ take 4 dif else [0, 0, 0, 0] tot = foldr (+) 0 dif formatMultiCpus :: [[Float]] -> Monitor [String] -formatMultiCpus [] = return $ take 15 (repeat "0%") +formatMultiCpus [] = return $ take 15 (repeat " 0%") formatMultiCpus xs = fmap concat $ mapM formatCpu xs formatCpu :: [Float] -> Monitor [String] formatCpu x | length x < 4 = return $ take 5 (repeat "") | otherwise = mapM (showWithColors f) . map (* 100) $ (t:x) - where f s = floatToPercent (s / 100) + where f s = pad $ floatToPercent (s / 100) t = foldr (+) 0 $ take 3 x + pad s = take (4 - length s) (repeat ' ') ++ s runMultiCpu :: [String] -> Monitor String runMultiCpu _ = -- cgit v1.2.3