diff options
author | Zev Weiss <zev@bewilderbeest.net> | 2016-11-04 14:36:04 -0500 |
---|---|---|
committer | Zev Weiss <zev@bewilderbeest.net> | 2016-11-04 14:36:04 -0500 |
commit | 35ca0c36f251003a2123433035b6f3a838cff4a4 (patch) | |
tree | 84d4c5ec13ed83fc8cef9e5cceb3b142e4358a90 | |
parent | f2d33fa9a2a613fd19c41323f2f11941f8a08e27 (diff) | |
download | xmobar-35ca0c36f251003a2123433035b6f3a838cff4a4.tar.gz xmobar-35ca0c36f251003a2123433035b6f3a838cff4a4.tar.bz2 |
Fix MultiCpu monitor for large uptimes
This is essentially commit a0397ad2 applied to MultiCpu.
-rw-r--r-- | src/Plugins/Monitors/MultiCpu.hs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/Plugins/Monitors/MultiCpu.hs b/src/Plugins/Monitors/MultiCpu.hs index eab21da..f0cdec4 100644 --- a/src/Plugins/Monitors/MultiCpu.hs +++ b/src/Plugins/Monitors/MultiCpu.hs @@ -58,15 +58,15 @@ multiCpuConfig = [ k ++ n | n <- "" : map show [0 :: Int ..] , k <- variables] -type CpuDataRef = IORef [[Float]] +type CpuDataRef = IORef [[Int]] -cpuData :: IO [[Float]] +cpuData :: IO [[Int]] cpuData = parse `fmap` B.readFile "/proc/stat" where parse = map parseList . cpuLists cpuLists = takeWhile isCpu . map B.words . B.lines isCpu (w:_) = "cpu" `isPrefixOf` B.unpack w isCpu _ = False - parseList = map (parseFloat . B.unpack) . tail + parseList = map (parseInt . B.unpack) . tail parseCpuData :: CpuDataRef -> IO [[Float]] parseCpuData cref = @@ -76,9 +76,9 @@ parseCpuData cref = let p0 = zipWith percent bs as return p0 -percent :: [Float] -> [Float] -> [Float] +percent :: [Int] -> [Int] -> [Float] percent b a = if tot > 0 then map (/ tot) $ take 4 dif else [0, 0, 0, 0] - where dif = zipWith (-) b a + where dif = map fromIntegral $ zipWith (-) b a tot = sum dif formatMultiCpus :: MultiCpuOpts -> [[Float]] -> Monitor [String] |