summaryrefslogtreecommitdiffhomepage
path: root/src/Plugins/Monitors
diff options
context:
space:
mode:
authorBen Boeckel <mathstuf@gmail.com>2012-06-09 00:36:23 -0400
committerBen Boeckel <mathstuf@gmail.com>2012-06-09 00:37:01 -0400
commite513f7149000dfec4549d0d9f0a3add647e06c95 (patch)
tree861fa0ecffdf03f5b18b3d0611e234880a596f92 /src/Plugins/Monitors
parentad5439d9bd4b9822bdbe26d4102665ada487c756 (diff)
downloadxmobar-e513f7149000dfec4549d0d9f0a3add647e06c95.tar.gz
xmobar-e513f7149000dfec4549d0d9f0a3add647e06c95.tar.bz2
Add runM variant which takes a blocking call
This allows monitors to define update times other than time-based.
Diffstat (limited to 'src/Plugins/Monitors')
-rw-r--r--src/Plugins/Monitors/Common.hs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/Plugins/Monitors/Common.hs b/src/Plugins/Monitors/Common.hs
index c9f0843..7fcab1f 100644
--- a/src/Plugins/Monitors/Common.hs
+++ b/src/Plugins/Monitors/Common.hs
@@ -23,6 +23,7 @@ module Plugins.Monitors.Common (
, getConfigValue
, mkMConfig
, runM
+ , runMB
, io
-- * Parsers
-- $parsers
@@ -207,9 +208,13 @@ doConfigOptions (o:oo) =
runM :: [String] -> IO MConfig -> ([String] -> Monitor String) -> Int
-> (String -> IO ()) -> IO ()
-runM args conf action r cb = handle (cb . showException) loop
+runM args conf action r = runMB args conf action (tenthSeconds r)
+
+runMB :: [String] -> IO MConfig -> ([String] -> Monitor String)
+ -> IO () -> (String -> IO ()) -> IO ()
+runMB args conf action wait cb = handle (cb . showException) loop
where ac = doArgs args action
- loop = conf >>= runReaderT ac >>= cb >> tenthSeconds r >> loop
+ loop = conf >>= runReaderT ac >>= cb >> wait >> loop
showException :: SomeException -> String
showException = ("error: "++) . show . flip asTypeOf undefined