summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-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