From 7aeb01c7dc010bd621d22bf342c599b4df9a1392 Mon Sep 17 00:00:00 2001 From: jao Date: Thu, 23 May 2019 17:56:15 +0100 Subject: New DiskIO template variables with bytes rather than speed (#390) --- changelog.md | 9 +++++++++ readme.md | 14 +++++++++----- src/Xmobar/Plugins/Monitors/Disk.hs | 25 ++++++++++++++++++------- 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/changelog.md b/changelog.md index 3ddbb43..34d1ef2 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,12 @@ +## Version 0.30 + +_New features_ + + - `DiskIO`: Additional template variables for absolute number of + bytes rather than speeds (see [issue #390]. + +[issue #390]: https://github.com/jaor/xmobar/issues/390 + ## Version 0.29.5 (March, 2019) _Bug fixes_ diff --git a/readme.md b/readme.md index e66830b..6834eaf 100644 --- a/readme.md +++ b/readme.md @@ -964,11 +964,15 @@ more than one battery. - Aliases to `diskio` - Disks: list of pairs of the form (device or mount point, template), - where the template can contain ``, ``, `` for total, - read and write speed, respectively. There are also bar versions of each: - ``, ``, ``, - ``, ``, ``, - ``, ``, and ``. + where the template can contain ``, ``, `` for + total, read and write speed, respectively, as well as ``, + ``, ``, which report number of bytes during the last + refresh period rather than speed. There are also bar versions of + each: ``, ``, ``, ``, + ``, ``, ``, ``, and + ``; and their "bytes" counterparts: ``, + ``, ``, ``, ``, + ``, ``, ``, and ``. - Thresholds refer to speed in b/s - Args: default monitor arguments. `-t`/`--template` is ignored. Plus - `--total-icon-pattern`: dynamic string for total disk I/O in ``. diff --git a/src/Xmobar/Plugins/Monitors/Disk.hs b/src/Xmobar/Plugins/Monitors/Disk.hs index 3f89629..0305d78 100644 --- a/src/Xmobar/Plugins/Monitors/Disk.hs +++ b/src/Xmobar/Plugins/Monitors/Disk.hs @@ -1,7 +1,7 @@ ----------------------------------------------------------------------------- -- | -- Module : Plugins.Monitors.Disk --- Copyright : (c) 2010, 2011, 2012, 2014, 2018 Jose A Ortega Ruiz +-- Copyright : (c) 2010, 2011, 2012, 2014, 2018, 2019 Jose A Ortega Ruiz -- License : BSD-style (see LICENSE) -- -- Maintainer : Jose A Ortega Ruiz @@ -54,9 +54,13 @@ parseDiskIOOpts argv = diskIOConfig :: IO MConfig diskIOConfig = mkMConfig "" ["total", "read", "write" + ,"totalb", "readb", "writeb" ,"totalbar", "readbar", "writebar" + ,"totalbbar", "readbbar", "writebbar" ,"totalvbar", "readvbar", "writevbar" + ,"totalbvbar", "readbvbar", "writebvbar" ,"totalipat", "readipat", "writeipat" + ,"totalbipat", "readbipat", "writebipat" ] data DiskUOpts = DiskUOpts @@ -148,11 +152,16 @@ parseDev dat dev = case find ((==dev) . fst) dat of Nothing -> (dev, [0, 0, 0]) Just (_, xs) -> - let rSp = speed (xs !! 2) (xs !! 3) - wSp = speed (xs !! 6) (xs !! 7) - sp = speed (xs !! 2 + xs !! 6) (xs !! 3 + xs !! 7) - speed x t = if t == 0 then 0 else 500 * x / t - dat' = if length xs > 6 then [sp, rSp, wSp] else [0, 0, 0] + let r = xs !! 2 + w = xs !! 6 + t = r + w + rSp = speed r (xs !! 3) + wSp = speed w (xs !! 7) + sp = speed t (xs !! 3 + xs !! 7) + speed x d = if d == 0 then 0 else 500 * x / d + dat' = if length xs > 6 + then [sp, rSp, wSp, t, r, w] + else [0, 0, 0, 0, 0, 0] in (dev, dat') speedToStr :: Float -> String @@ -184,7 +193,9 @@ runDiskIO' opts (tmp, xs) = do b <- mapM (showLogBar 0.8) xs vb <- mapM (showLogVBar 0.8) xs ipat <- mapM (\(f,v) -> showLogIconPattern (f opts) 0.8 v) - $ zip [totalIconPattern, readIconPattern, writeIconPattern] xs + $ zip [totalIconPattern, readIconPattern, writeIconPattern + , totalIconPattern, readIconPattern, writeIconPattern] + xs setConfigValue tmp template parseTemplate $ s ++ b ++ vb ++ ipat -- cgit v1.2.3