From 6173b1cab8a5df50de7d72eb42f3ababae782e49 Mon Sep 17 00:00:00 2001 From: jao Date: Sat, 12 Oct 2019 15:33:10 +0100 Subject: toggleMonitor --- src/lib/Monitors.hs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') 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" , " \ \ยท " -- cgit v1.2.3