diff options
author | jao <jao@gnu.org> | 2019-10-12 15:33:10 +0100 |
---|---|---|
committer | jao <jao@gnu.org> | 2019-10-12 15:33:24 +0100 |
commit | 6173b1cab8a5df50de7d72eb42f3ababae782e49 (patch) | |
tree | c707de57adef8cc24dec3dd1b6b2c04dc7d92af0 /src/lib | |
parent | 55981bd182a38ddff96bed317dafb8e54cb697e5 (diff) | |
download | xmobar-config-6173b1cab8a5df50de7d72eb42f3ababae782e49.tar.gz xmobar-config-6173b1cab8a5df50de7d72eb42f3ababae782e49.tar.bz2 |
toggleMonitor
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/Monitors.hs | 12 |
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>" |