diff options
author | Jose A. Ortega Ruiz <jao@gnu.org> | 2010-01-20 22:56:08 +0100 |
---|---|---|
committer | Jose A. Ortega Ruiz <jao@gnu.org> | 2010-01-20 22:56:08 +0100 |
commit | 528dfc748ffbde6c83333daefd2b265dcd62f206 (patch) | |
tree | bd5623ec54ee5d67bb699cb20240c2581a5868df /Plugins/Monitors/Swap.hs | |
parent | 2d6911f940ec82c2054cf96b151ac9ff61372865 (diff) | |
download | xmobar-528dfc748ffbde6c83333daefd2b265dcd62f206.tar.gz xmobar-528dfc748ffbde6c83333daefd2b265dcd62f206.tar.bz2 |
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
Diffstat (limited to 'Plugins/Monitors/Swap.hs')
-rw-r--r-- | Plugins/Monitors/Swap.hs | 11 |
1 files changed, 5 insertions, 6 deletions
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 <andrea.rossato@unibz.it> -- 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 |