diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-12-09 02:56:01 +0100 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-12-09 02:56:01 +0100 |
commit | ab7ed89ffcb4abc7cc42bfa599d7e15791c6e541 (patch) | |
tree | 348d514fd316b4841d01a01b576d2459fffc5cb1 | |
parent | 9b688ee9a5cd2147c9d755d5d7410170197054ad (diff) | |
parent | 0054cc5beec8fe7673443f3a4a6a7a878a7f400d (diff) | |
download | xmobar-ab7ed89ffcb4abc7cc42bfa599d7e15791c6e541.tar.gz xmobar-ab7ed89ffcb4abc7cc42bfa599d7e15791c6e541.tar.bz2 |
Merge branch 'dev/auto-per-core-cpu-usage' of https://github.com/mathstuf/xmobar into mathstuf-dev/auto-per-core-cpu-usage
-rw-r--r-- | Plugins/Monitors/MultiCpu.hs | 24 | ||||
-rw-r--r-- | README | 8 |
2 files changed, 25 insertions, 7 deletions
diff --git a/Plugins/Monitors/MultiCpu.hs b/Plugins/Monitors/MultiCpu.hs index 069199b..17620d5 100644 --- a/Plugins/Monitors/MultiCpu.hs +++ b/Plugins/Monitors/MultiCpu.hs @@ -16,13 +16,15 @@ module Plugins.Monitors.MultiCpu(multiCpuConfig, runMultiCpu) where import Plugins.Monitors.Common import qualified Data.ByteString.Lazy.Char8 as B -import Data.List (isPrefixOf) +import Data.List (isPrefixOf,intersperse,transpose) multiCpuConfig :: IO MConfig multiCpuConfig = - mkMConfig "Cpu: <total>%" - [ k ++ n | n <- "" : map show [0 :: Int ..] - , k <- ["bar","total","user","nice","system","idle"]] + mkMConfig "Cpu: <total>%" $ + map ("auto" ++) monitors + ++ [ k ++ n | n <- "" : map show [0 :: Int ..] + , k <- monitors] + where monitors = ["bar","total","user","nice","system","idle"] cpuData :: IO [[Float]] @@ -59,8 +61,20 @@ formatCpu xs ps <- showPercentsWithColors (t:xs) return (b:ps) +splitEvery :: Int -> [a] -> [[a]] +splitEvery _ [] = [] +splitEvery n l = (take n l) : splitEvery n (drop n l) + +groupData :: [String] -> [[String]] +groupData = transpose . tail . splitEvery 6 + +formatAutoCpus :: [String] -> Monitor [String] +formatAutoCpus [] = return $ replicate 6 "" +formatAutoCpus xs = return $ map concat . map (intersperse " ") $ groupData xs + runMultiCpu :: [String] -> Monitor String runMultiCpu _ = do c <- io parseCpuData l <- formatMultiCpus c - parseTemplate l + a <- formatAutoCpus l + parseTemplate (a ++ l) @@ -374,8 +374,12 @@ Monitors have default aliases. - aliases to `multicpu` - Args: default monitor arguments (see below) - Variables that can be used with the `-t`/`--template` argument: - `total`, `bar`, `user`, `nice`, `system`, `idle`, - `total0`, `bar0`, `user0`, `nice0`, `system0`, `idle0`, ... + `autototal`, `autobar`, `autouser`, `autonice`, + `autosystem`, `autoidle`, `total`, `bar`, `user`, `nice`, + `system`, `idle`, `total0`, `bar0`, `user0`, `nice0`, + `system0`, `idle0`, ... +- The auto* variables automatically detect the number of CPUs on the system + and displays one entry for each. - Default template: `Cpu: <total>%` `Battery Args RefreshRate` |