summaryrefslogtreecommitdiffhomepage
path: root/Plugins/Monitors/Mem.hs
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2010-12-21 02:36:35 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2010-12-21 02:36:35 +0100
commite3853a9cb2a9a2cffa174d1334e2ca8ba610f151 (patch)
tree13aa04faea320afe85636e23686280386c1c2910 /Plugins/Monitors/Mem.hs
parent598bfe5deeff079280e8513c55dc7bda3e8cf9a0 (diff)
downloadxmobar-e3853a9cb2a9a2cffa174d1334e2ca8ba610f151.tar.gz
xmobar-e3853a9cb2a9a2cffa174d1334e2ca8ba610f151.tar.bz2
Haskell sources moved to src/ to unclutter toplevel
Diffstat (limited to 'Plugins/Monitors/Mem.hs')
-rw-r--r--Plugins/Monitors/Mem.hs59
1 files changed, 0 insertions, 59 deletions
diff --git a/Plugins/Monitors/Mem.hs b/Plugins/Monitors/Mem.hs
deleted file mode 100644
index 5c55ee2..0000000
--- a/Plugins/Monitors/Mem.hs
+++ /dev/null
@@ -1,59 +0,0 @@
------------------------------------------------------------------------------
--- |
--- Module : Plugins.Monitors.Mem
--- Copyright : (c) Andrea Rossato
--- License : BSD-style (see LICENSE)
---
--- Maintainer : Jose A. Ortega Ruiz <jao@gnu.org>
--- Stability : unstable
--- Portability : unportable
---
--- A memory monitor for Xmobar
---
------------------------------------------------------------------------------
-
-module Plugins.Monitors.Mem (memConfig, runMem, totalMem, usedMem) where
-
-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
-
-fileMEM :: IO String
-fileMEM = readFile "/proc/meminfo"
-
-parseMEM :: IO [Float]
-parseMEM =
- 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 / 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 = showDigits 0
- rr = 100 * r
- ub <- showPercentBar rr r
- fb <- showPercentBar (100 - rr) (1 - r)
- rs <- showPercentWithColors r
- s <- mapM (showWithColors f) xs
- return (ub:fb:rs:s)
-formatMem _ = return $ replicate 9 "N/A"
-
-runMem :: [String] -> Monitor String
-runMem _ =
- do m <- io parseMEM
- l <- formatMem m
- parseTemplate l