summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorPeter Simons <simons@cryp.to>2013-03-08 11:58:15 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2013-03-18 21:21:44 +0100
commitfc79ec5cb9a9d63e189d32aa0a0cb0bf3c065e37 (patch)
tree36f8553dd01f82f4f0cd94a835167bccad9172bd /src
parent55522d3c6d43da03a8ce1869f4d29dfb2237310b (diff)
downloadxmobar-fc79ec5cb9a9d63e189d32aa0a0cb0bf3c065e37.tar.gz
xmobar-fc79ec5cb9a9d63e189d32aa0a0cb0bf3c065e37.tar.bz2
Introduce <freeratio> variable into the memory monitor.
Diffstat (limited to 'src')
-rw-r--r--src/Plugins/Monitors/Mem.hs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/Plugins/Monitors/Mem.hs b/src/Plugins/Monitors/Mem.hs
index 5c55ee2..3cf46c7 100644
--- a/src/Plugins/Monitors/Mem.hs
+++ b/src/Plugins/Monitors/Mem.hs
@@ -19,8 +19,8 @@ import Plugins.Monitors.Common
memConfig :: IO MConfig
memConfig = mkMConfig
"Mem: <usedratio>% (<cache>M)" -- template
- ["usedbar", "freebar", "usedratio", "total",
- "free", "buffer", "cache", "rest", "used"] -- available replacements
+ ["usedbar", "freebar", "usedratio", "freeratio", "total",
+ "free", "buffer", "cache", "rest", "used"] -- available replacements
fileMEM :: IO String
fileMEM = readFile "/proc/meminfo"
@@ -33,7 +33,8 @@ parseMEM =
rest = free + buffer + cache
used = total - rest
usedratio = used / total
- return [usedratio, total, free, buffer, cache, rest, used]
+ freeratio = free / total
+ return [usedratio, freeratio, total, free, buffer, cache, rest, used, freeratio]
totalMem :: IO Float
totalMem = fmap ((*1024) . (!!1)) parseMEM
@@ -42,15 +43,16 @@ usedMem :: IO Float
usedMem = fmap ((*1024) . (!!6)) parseMEM
formatMem :: [Float] -> Monitor [String]
-formatMem (r:xs) =
+formatMem (r:fr:xs) =
do let f = showDigits 0
rr = 100 * r
ub <- showPercentBar rr r
fb <- showPercentBar (100 - rr) (1 - r)
rs <- showPercentWithColors r
+ fs <- showPercentWithColors fr
s <- mapM (showWithColors f) xs
- return (ub:fb:rs:s)
-formatMem _ = return $ replicate 9 "N/A"
+ return (ub:fb:rs:fs:s)
+formatMem _ = return $ replicate 10 "N/A"
runMem :: [String] -> Monitor String
runMem _ =