From dc171e4a07e597f9f5d7839c231b8b9c3ae19437 Mon Sep 17 00:00:00 2001 From: Jose A Ortega Ruiz Date: Fri, 19 Mar 2010 21:33:24 +0100 Subject: Usage bars Ignore-this: 63fd21a117029674e33a9c4419dbc4de ASCII art bars for a bunch of monitors. darcs-hash:20100319203324-748be-2f927aa0e16d8874e10a04f0245427d32e0e53ce.gz --- Plugins/Monitors/MultiCpu.hs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'Plugins/Monitors/MultiCpu.hs') diff --git a/Plugins/Monitors/MultiCpu.hs b/Plugins/Monitors/MultiCpu.hs index 360671b..223ff24 100644 --- a/Plugins/Monitors/MultiCpu.hs +++ b/Plugins/Monitors/MultiCpu.hs @@ -19,10 +19,10 @@ import qualified Data.ByteString.Lazy.Char8 as B import Data.List (isPrefixOf) multiCpuConfig :: IO MConfig -multiCpuConfig = mkMConfig - "Cpu: " - [ k ++ n | n <- "" : map show [0 :: Int ..] - , k <- ["total","user","nice","system","idle"]] +multiCpuConfig = + mkMConfig "Cpu: " + [ k ++ n | n <- "" : map show [0 :: Int ..] + , k <- ["bar","total","user","nice","system","idle"]] cpuData :: IO [[Float]] @@ -53,8 +53,11 @@ formatMultiCpus xs = fmap concat $ mapM formatCpu xs formatCpu :: [Float] -> Monitor [String] formatCpu xs - | length xs < 4 = showPercentsWithColors $ replicate 5 0.0 - | otherwise = showPercentsWithColors $ (foldr (+) 0 $ take 3 xs) : xs + | length xs < 4 = showPercentsWithColors $ replicate 6 0.0 + | otherwise = let t = foldr (+) 0 $ take 3 xs + in do b <- showPercentBar (100 * t) t + ps <- showPercentsWithColors (t:xs) + return (b:ps) runMultiCpu :: [String] -> Monitor String runMultiCpu _ = -- cgit v1.2.3