summaryrefslogtreecommitdiffhomepage
path: root/src/lib/Monitors.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Monitors.hs')
-rw-r--r--src/lib/Monitors.hs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/lib/Monitors.hs b/src/lib/Monitors.hs
index 5639185..0dbe8b1 100644
--- a/src/lib/Monitors.hs
+++ b/src/lib/Monitors.hs
@@ -25,16 +25,20 @@ startMonitors a b cmb = do
stb <- atomically $ newTVar ""
_ <- async $ start a (\x -> atomically $ writeTVar sta x)
_ <- async $ start b (\x -> atomically $ writeTVar stb x)
- go sta stb cmb
- where go sta' stb' cmb' = do
+ go sta stb
+ where go sta' stb' = do
s <- atomically $ readTVar sta'
t <- atomically $ readTVar stb'
- cmb' s t
+ cmb s t
tenthSeconds $ min (rate b) (rate a)
- go sta' stb' cmb'
+ go sta' stb'
+
+guardedMonitor a p = CombinedMonitor (PipeReader p (alias a ++ "_g")) a f
+ where f s t = if (null s || head s == '0') then "" else t
altMonitor a b = CombinedMonitor a b (\s t -> if null s then t else s)
concatMonitor sep a b = CombinedMonitor a b (\s t -> s ++ sep ++ t)
+toggleMonitor path a b = altMonitor (guardedMonitor a path) b
topProc p = TopProc (p <~> ["-t" , "<mboth3> <mboth2> <mboth1> \
\ยท <both3> <both2> <both1>"