summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBen Boeckel <mathstuf@gmail.com>2014-02-04 22:49:33 -0500
committerBen Boeckel <mathstuf@gmail.com>2014-02-04 22:52:46 -0500
commit70fe560d6e66c6f5a44511f70d06977cde32215b (patch)
tree33591cf07014311db88f99f73c3145e84ce2c8b4
parent8b72489b273edcd69be69b8693bc3eccfeb4404c (diff)
downloadxmobar-70fe560d6e66c6f5a44511f70d06977cde32215b.tar.gz
xmobar-70fe560d6e66c6f5a44511f70d06977cde32215b.tar.bz2
Use MemAvailable from meminfo if possible
Use the functionality from newer kernels if available. Basically, the free+buffer+cache metric is a massive hack and not accurate anyways (e.g., not all cache can be swapped out and kernel accounting can change whenever). Kernels 3.14 and newer have MemAvailable in meminfo which is more accurate; use it if possible.
-rw-r--r--src/Plugins/Monitors/Mem.hs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/Plugins/Monitors/Mem.hs b/src/Plugins/Monitors/Mem.hs
index 47a4c3f..d7b6754 100644
--- a/src/Plugins/Monitors/Mem.hs
+++ b/src/Plugins/Monitors/Mem.hs
@@ -33,7 +33,7 @@ parseMEM =
info = M.fromList $ map (\line -> (line !! 0, (read $ line !! 1 :: Float) / 1024)) content
[total, free, buffer, cache] = map (info M.!) ["MemTotal:", "MemFree:", "Buffers:", "Cached:"]
rest = free + buffer + cache
- used = total - rest
+ used = total - (M.findWithDefault rest "MemAvailable:" info)
usedratio = used / total
freeratio = free / total
return [usedratio, freeratio, total, free, buffer, cache, rest, used, freeratio]