summaryrefslogtreecommitdiffhomepage
path: root/Plugins/Monitors/Cpu.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/Cpu.hs
parent598bfe5deeff079280e8513c55dc7bda3e8cf9a0 (diff)
downloadxmobar-e3853a9cb2a9a2cffa174d1334e2ca8ba610f151.tar.gz
xmobar-e3853a9cb2a9a2cffa174d1334e2ca8ba610f151.tar.bz2
Haskell sources moved to src/ to unclutter toplevel
Diffstat (limited to 'Plugins/Monitors/Cpu.hs')
-rw-r--r--Plugins/Monitors/Cpu.hs53
1 files changed, 0 insertions, 53 deletions
diff --git a/Plugins/Monitors/Cpu.hs b/Plugins/Monitors/Cpu.hs
deleted file mode 100644
index ab89246..0000000
--- a/Plugins/Monitors/Cpu.hs
+++ /dev/null
@@ -1,53 +0,0 @@
------------------------------------------------------------------------------
--- |
--- Module : Plugins.Monitors.Cpu
--- Copyright : (c) Andrea Rossato
--- License : BSD-style (see LICENSE)
---
--- Maintainer : Jose A. Ortega Ruiz <jao@gnu.org>
--- Stability : unstable
--- Portability : unportable
---
--- A cpu monitor for Xmobar
---
------------------------------------------------------------------------------
-
-module Plugins.Monitors.Cpu where
-
-import Plugins.Monitors.Common
-import qualified Data.ByteString.Lazy.Char8 as B
-
-cpuConfig :: IO MConfig
-cpuConfig = mkMConfig
- "Cpu: <total>%"
- ["bar","total","user","nice","system","idle"]
-
-cpuData :: IO [Float]
-cpuData = do s <- B.readFile "/proc/stat"
- return $ cpuParser s
-
-cpuParser :: B.ByteString -> [Float]
-cpuParser =
- map (read . B.unpack) . tail . B.words . head . B.lines
-
-parseCPU :: IO [Float]
-parseCPU =
- do (a,b) <- doActionTwiceWithDelay 750000 cpuData
- let dif = zipWith (-) b a
- tot = foldr (+) 0 dif
- percent = map (/ tot) dif
- return percent
-
-formatCpu :: [Float] -> Monitor [String]
-formatCpu [] = return $ repeat ""
-formatCpu xs = do
- let t = foldr (+) 0 $ take 3 xs
- b <- showPercentBar (100 * t) t
- ps <- showPercentsWithColors (t:xs)
- return (b:ps)
-
-runCpu :: [String] -> Monitor String
-runCpu _ =
- do c <- io parseCPU
- l <- formatCpu c
- parseTemplate l