summaryrefslogtreecommitdiffhomepage
path: root/Plugins/Monitors/Mem.hs
diff options
context:
space:
mode:
authorJose A Ortega Ruiz <jao@gnu.org>2010-03-26 04:09:56 +0100
committerJose A Ortega Ruiz <jao@gnu.org>2010-03-26 04:09:56 +0100
commit9778203cf27e77a9ba6620423395a04642a640b7 (patch)
treea71fd48fccd37a89382144d39981ee4452b3c60d /Plugins/Monitors/Mem.hs
parentf6b0e885b7359f60d6da826b3bf8ca4301bb5f8c (diff)
downloadxmobar-9778203cf27e77a9ba6620423395a04642a640b7.tar.gz
xmobar-9778203cf27e77a9ba6620423395a04642a640b7.tar.bz2
Less resource hungry Top monitors.
Ignore-this: f963302295a675773ab3bfd54e458a0d darcs-hash:20100326030956-748be-df70f254d1274a3f4b576df392cf6c30a0f1f582.gz
Diffstat (limited to 'Plugins/Monitors/Mem.hs')
-rw-r--r--Plugins/Monitors/Mem.hs14
1 files changed, 10 insertions, 4 deletions
diff --git a/Plugins/Monitors/Mem.hs b/Plugins/Monitors/Mem.hs
index c6c4dc4..f493862 100644
--- a/Plugins/Monitors/Mem.hs
+++ b/Plugins/Monitors/Mem.hs
@@ -12,7 +12,7 @@
--
-----------------------------------------------------------------------------
-module Plugins.Monitors.Mem where
+module Plugins.Monitors.Mem (memConfig, runMem, totalMem, usedMem) where
import Plugins.Monitors.Common
@@ -35,18 +35,24 @@ parseMEM =
usedratio = used / total
return [usedratio, total, free, buffer, cache, rest, used]
+totalMem :: IO Float
+totalMem = fmap ((*1024) . (!!1)) parseMEM
+
+usedMem :: IO Float
+usedMem = fmap ((*1024) . (!!6)) parseMEM
+
formatMem :: [Float] -> Monitor [String]
formatMem (r:xs) =
- do let f n = showDigits 0 n
+ do let f = showDigits 0
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"
+formatMem _ = return $ replicate 9 "N/A"
runMem :: [String] -> Monitor String
runMem _ =
- do m <- io $ parseMEM
+ do m <- io parseMEM
l <- formatMem m
parseTemplate l