summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2019-05-23 17:56:15 +0100
committerjao <jao@gnu.org>2019-05-23 17:56:15 +0100
commit7aeb01c7dc010bd621d22bf342c599b4df9a1392 (patch)
tree96c29e8e7668df354a37f2acb2bd3225b487037e
parent0ff8f6a7d6c775efa35698e067b4dd6c036ee2cd (diff)
downloadxmobar-7aeb01c7dc010bd621d22bf342c599b4df9a1392.tar.gz
xmobar-7aeb01c7dc010bd621d22bf342c599b4df9a1392.tar.bz2
New DiskIO template variables with bytes rather than speed (#390)
-rw-r--r--changelog.md9
-rw-r--r--readme.md14
-rw-r--r--src/Xmobar/Plugins/Monitors/Disk.hs25
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 `<total>`, `<read>`, `<write>` for total,
- read and write speed, respectively. There are also bar versions of each:
- `<totalbar>`, `<totalvbar>`, `<totalipat>`,
- `<readbar>`, `<readvbar>`, `<readipat>`,
- `<writebar>`, `<writevbar>`, and `<writeipat>`.
+ where the template can contain `<total>`, `<read>`, `<write>` for
+ total, read and write speed, respectively, as well as `<totalb>`,
+ `<readb>`, `<writeb>`, which report number of bytes during the last
+ refresh period rather than speed. There are also bar versions of
+ each: `<totalbar>`, `<totalvbar>`, `<totalipat>`, `<readbar>`,
+ `<readvbar>`, `<readipat>`, `<writebar>`, `<writevbar>`, and
+ `<writeipat>`; and their "bytes" counterparts: `<totalbbar>`,
+ `<totalbvbar>`, `<totalbipat>`, `<readbbar>`, `<readbvbar>`,
+ `<readbipat>`, `<writebbar>`, `<writebvbar>`, and `<writebipat>`.
- 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 `<totalipat>`.
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 <jao@gnu.org>
@@ -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