From 528dfc748ffbde6c83333daefd2b265dcd62f206 Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Wed, 20 Jan 2010 22:56:08 +0100 Subject: New Monitor option to specify minimum percentage width Ignore-this: 5e0413c218f257c0db06f83665bd2e5 The new option, -p, is a number specifying how many characters the numerical part of percentages should take. Padding consists of whitespace. E.g. -p 3 makes '3%' appear as ' 3%'. The default value is 0, which means padding is disabled. darcs-hash:20100120215608-40885-2c2ac6718af740971dad491eea92947bae840163.gz --- Plugins/Monitors/Swap.hs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'Plugins/Monitors/Swap.hs') diff --git a/Plugins/Monitors/Swap.hs b/Plugins/Monitors/Swap.hs index 40c21ed..02acb45 100644 --- a/Plugins/Monitors/Swap.hs +++ b/Plugins/Monitors/Swap.hs @@ -3,7 +3,7 @@ -- Module : Plugins.Monitors.Swap -- Copyright : (c) Andrea Rossato -- License : BSD-style (see LICENSE) --- +-- -- Maintainer : Andrea Rossato -- Stability : unstable -- Portability : unportable @@ -30,7 +30,7 @@ parseMEM :: IO [Float] parseMEM = do file <- fileMEM let li i l - | l /= [] = (head l) !! i + | l /= [] = (head l) !! i | otherwise = B.empty fs s l | l == [] = False @@ -41,17 +41,16 @@ parseMEM = free = get_data "SwapFree:" st return [tot, (tot - free), free, (tot - free) / tot] -formatSwap :: [Float] -> Monitor [String] +formatSwap :: [Float] -> Monitor [String] formatSwap x = do let f1 n = showDigits 2 n - f2 n = floatToPercent n (hd, tl) = splitAt 3 x firsts <- mapM (showWithColors f1) hd - lasts <- mapM (showWithColors f2) tl + lasts <- showPercentsWithColors (map (/100) tl) return $ firsts ++ lasts runSwap :: [String] -> Monitor String runSwap _ = do m <- io $ parseMEM l <- formatSwap m - parseTemplate l + parseTemplate l -- cgit v1.2.3