diff options
author | Eric Mrak <mail@ericmrak.info> | 2014-03-13 19:41:42 -0700 |
---|---|---|
committer | Eric Mrak <mail@ericmrak.info> | 2014-03-13 20:07:54 -0700 |
commit | c7667a521264a7f2d397b651f7991664349d6897 (patch) | |
tree | 47ee0170c9d134fd358d23df6cdbfc52db6ca1dd /src | |
parent | 3e5a0a6c8e231db39c4d2593abb035ee0d5149df (diff) | |
download | xmobar-c7667a521264a7f2d397b651f7991664349d6897.tar.gz xmobar-c7667a521264a7f2d397b651f7991664349d6897.tar.bz2 |
MultiCpu now has vbar
Diffstat (limited to 'src')
-rw-r--r-- | src/Plugins/Monitors/MultiCpu.hs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/Plugins/Monitors/MultiCpu.hs b/src/Plugins/Monitors/MultiCpu.hs index a1bb082..48c0bc1 100644 --- a/src/Plugins/Monitors/MultiCpu.hs +++ b/src/Plugins/Monitors/MultiCpu.hs @@ -19,13 +19,15 @@ import qualified Data.ByteString.Lazy.Char8 as B import Data.List (isPrefixOf, transpose, unfoldr) import Data.IORef (IORef, newIORef, readIORef, writeIORef) +variables = ["bar", "vbar","total","user","nice","system","idle"] +vNum = length variables + multiCpuConfig :: IO MConfig multiCpuConfig = mkMConfig "Cpu: <total>%" $ - ["auto" ++ k | k <- monitors] ++ + ["auto" ++ k | k <- variables] ++ [ k ++ n | n <- "" : map show [0 :: Int ..] - , k <- monitors] - where monitors = ["bar","total","user","nice","system","idle"] + , k <- variables] type CpuDataRef = IORef [[Float]] @@ -56,20 +58,21 @@ formatMultiCpus xs = fmap concat $ mapM formatCpu xs formatCpu :: [Float] -> Monitor [String] formatCpu xs - | length xs < 4 = showPercentsWithColors $ replicate 6 0.0 + | length xs < 4 = showPercentsWithColors $ replicate vNum 0.0 | otherwise = let t = foldr (+) 0 $ take 3 xs in do b <- showPercentBar (100 * t) t + h <- showVerticalBar (100 * t) ps <- showPercentsWithColors (t:xs) - return (b:ps) + return (b:h:ps) splitEvery :: (Eq a) => Int -> [a] -> [[a]] splitEvery n = unfoldr (\x -> if null x then Nothing else Just $ splitAt n x) groupData :: [String] -> [[String]] -groupData = transpose . tail . splitEvery 6 +groupData = transpose . tail . splitEvery vNum formatAutoCpus :: [String] -> Monitor [String] -formatAutoCpus [] = return $ replicate 6 "" +formatAutoCpus [] = return $ replicate vNum "" formatAutoCpus xs = return $ map unwords (groupData xs) runMultiCpu :: CpuDataRef -> [String] -> Monitor String |