diff options
author | Jose A Ortega Ruiz <jao@gnu.org> | 2010-03-19 21:33:24 +0100 |
---|---|---|
committer | Jose A Ortega Ruiz <jao@gnu.org> | 2010-03-19 21:33:24 +0100 |
commit | dc171e4a07e597f9f5d7839c231b8b9c3ae19437 (patch) | |
tree | cae45f74db3ffd894b7fb593288ebc46538aede3 /Plugins/Monitors/Mem.hs | |
parent | 4f8ba03c51570925fb59e90e65747da37a2a4b65 (diff) | |
download | xmobar-dc171e4a07e597f9f5d7839c231b8b9c3ae19437.tar.gz xmobar-dc171e4a07e597f9f5d7839c231b8b9c3ae19437.tar.bz2 |
Usage bars
Ignore-this: 63fd21a117029674e33a9c4419dbc4de
ASCII art bars for a bunch of monitors.
darcs-hash:20100319203324-748be-2f927aa0e16d8874e10a04f0245427d32e0e53ce.gz
Diffstat (limited to 'Plugins/Monitors/Mem.hs')
-rw-r--r-- | Plugins/Monitors/Mem.hs | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/Plugins/Monitors/Mem.hs b/Plugins/Monitors/Mem.hs index 16fc3a4..c6c4dc4 100644 --- a/Plugins/Monitors/Mem.hs +++ b/Plugins/Monitors/Mem.hs @@ -3,7 +3,7 @@ -- Module : Plugins.Monitors.Mem -- Copyright : (c) Andrea Rossato -- License : BSD-style (see LICENSE) --- +-- -- Maintainer : Andrea Rossato <andrea.rossato@unibz.it> -- Stability : unstable -- Portability : unportable @@ -19,29 +19,34 @@ import Plugins.Monitors.Common memConfig :: IO MConfig memConfig = mkMConfig "Mem: <usedratio>% (<cache>M)" -- template - ["total", "free", "buffer", -- available replacements - "cache", "rest", "used", "usedratio"] + ["usedbar", "freebar", "usedratio", "total", -- available replacements + "free", "buffer", "cache", "rest", "used"] fileMEM :: IO String fileMEM = readFile "/proc/meminfo" parseMEM :: IO [Float] parseMEM = - do file <- fileMEM + do file <- fileMEM let content = map words $ take 4 $ lines file [total, free, buffer, cache] = map (\line -> (read $ line !! 1 :: Float) / 1024) content rest = free + buffer + cache used = total - rest - usedratio = used * 100 / total - return [total, free, buffer, cache, rest, used, usedratio] + usedratio = used / total + return [usedratio, total, free, buffer, cache, rest, used] formatMem :: [Float] -> Monitor [String] -formatMem x = +formatMem (r:xs) = do let f n = showDigits 0 n - mapM (showWithColors f) x + rr = 100 * r + ub <- showPercentBar rr r + fb <- showPercentBar (100 - rr) (1 - r) + s <- mapM (showWithColors f) (rr:xs) + return (ub:fb:s) +formatMem _ = return $ replicate 8 "N/A" runMem :: [String] -> Monitor String runMem _ = do m <- io $ parseMEM l <- formatMem m - parseTemplate l + parseTemplate l |