From a8653d8712c2d218adf3f70cef7e511060bed695 Mon Sep 17 00:00:00 2001 From: Andrea Rossato Date: Wed, 18 Jul 2007 17:12:11 +0200 Subject: Monitors are now a Plugin that can be removed from Config.hs darcs-hash:20070718151211-d6583-7e0e49c22d07feda72d03370fd592c196dfcc9c1.gz --- Monitors/Cpu.hs | 53 ----------------------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 Monitors/Cpu.hs (limited to 'Monitors/Cpu.hs') diff --git a/Monitors/Cpu.hs b/Monitors/Cpu.hs deleted file mode 100644 index 14acffb..0000000 --- a/Monitors/Cpu.hs +++ /dev/null @@ -1,53 +0,0 @@ ------------------------------------------------------------------------------ --- | --- Module : Monitors.Cpu --- Copyright : (c) Andrea Rossato --- License : BSD-style (see LICENSE) --- --- Maintainer : Andrea Rossato --- Stability : unstable --- Portability : unportable --- --- A cpu monitor for Xmobar --- ------------------------------------------------------------------------------ - -module Monitors.Cpu where - -import Monitors.Common -import qualified Data.ByteString.Lazy.Char8 as B - -cpuConfig :: IO MConfig -cpuConfig = mkMConfig - "Cpu: " -- template - ["total","user","nice","system","idle"] -- available replacements - -cpuData :: IO [Float] -cpuData = do s <- B.readFile "/proc/stat" - return $ cpuParser s - -cpuParser :: B.ByteString -> [Float] -cpuParser = - map read . map B.unpack . tail . B.words . flip (!!) 0 . 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 [""] -formatCpu x = - do let f s = floatToPercent (s / 100) - t = foldr (+) 0 $ take 3 x - list = t:x - mapM (showWithColors f) . map (* 100) $ list - -runCpu :: [String] -> Monitor String -runCpu _ = - do c <- io $ parseCPU - l <- formatCpu c - parseTemplate l -- cgit v1.2.3