summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrea Rossato <andrea.rossato@ing.unitn.it>2007-08-27 12:59:02 +0200
committerAndrea Rossato <andrea.rossato@ing.unitn.it>2007-08-27 12:59:02 +0200
commit5a743aa87ed7d1ce91a18b07b14d8c48af1eb335 (patch)
treec72dad5a29431dad17663cf6a34335a87cad509c
parente8a47ab8c4b5b19dcc59a17140bf090f194e07c6 (diff)
downloadxmobar-5a743aa87ed7d1ce91a18b07b14d8c48af1eb335.tar.gz
xmobar-5a743aa87ed7d1ce91a18b07b14d8c48af1eb335.tar.bz2
Plugins.Swap: check for SwapFree and SwapTotal
In some system SwapFree and SwapTotal are in different position, so we need to check for the string. Reported by Stan Behrens darcs-hash:20070827105902-d6583-d0d1bd5341299759f2e600bd4173bfcb278dec40.gz
-rw-r--r--Plugins/Monitors/Swap.hs13
1 files changed, 10 insertions, 3 deletions
diff --git a/Plugins/Monitors/Swap.hs b/Plugins/Monitors/Swap.hs
index d18ab8a..40c21ed 100644
--- a/Plugins/Monitors/Swap.hs
+++ b/Plugins/Monitors/Swap.hs
@@ -29,9 +29,16 @@ fileMEM = B.readFile "/proc/meminfo"
parseMEM :: IO [Float]
parseMEM =
do file <- fileMEM
- let p x y = flip (/) 1024 . read . stringParser x $ y
- tot = p (1,11) file
- free = p (1,12) file
+ let li i l
+ | l /= [] = (head l) !! i
+ | otherwise = B.empty
+ fs s l
+ | l == [] = False
+ | otherwise = head l == B.pack s
+ get_data s = flip (/) 1024 . read . B.unpack . li 1 . filter (fs s)
+ st = map B.words . B.lines $ file
+ tot = get_data "SwapTotal:" st
+ free = get_data "SwapFree:" st
return [tot, (tot - free), free, (tot - free) / tot]
formatSwap :: [Float] -> Monitor [String]