summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--readme.md6
-rw-r--r--src/Plugins/Monitors/MultiCpu.hs17
2 files changed, 13 insertions, 10 deletions
diff --git a/readme.md b/readme.md
index 84c3946..5776aff 100644
--- a/readme.md
+++ b/readme.md
@@ -732,9 +732,9 @@ something like:
- Aliases to `multicpu`
- Args: default monitor arguments
- Variables that can be used with the `-t`/`--template` argument:
- `autototal`, `autobar`, `autouser`, `autonice`,
- `autosystem`, `autoidle`, `total`, `bar`, `user`, `nice`,
- `system`, `idle`, `total0`, `bar0`, `user0`, `nice0`,
+ `autototal`, `autobar`, `autovbar`, `autouser`, `autonice`,
+ `autosystem`, `autoidle`, `total`, `bar`, `vbar`, `user`, `nice`,
+ `system`, `idle`, `total0`, `bar0`, `vbar0`, `user0`, `nice0`,
`system0`, `idle0`, ...
The auto* variables automatically detect the number of CPUs on the system
and display one entry for each.
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