diff options
Diffstat (limited to 'src/Plugins/Monitors')
-rw-r--r-- | src/Plugins/Monitors/Common.hs | 9 | ||||
-rw-r--r-- | src/Plugins/Monitors/MPD.hs | 6 |
2 files changed, 12 insertions, 3 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 diff --git a/src/Plugins/Monitors/MPD.hs b/src/Plugins/Monitors/MPD.hs index e56260d..450ad8f 100644 --- a/src/Plugins/Monitors/MPD.hs +++ b/src/Plugins/Monitors/MPD.hs @@ -12,7 +12,7 @@ -- ----------------------------------------------------------------------------- -module Plugins.Monitors.MPD ( mpdConfig, runMPD ) where +module Plugins.Monitors.MPD ( mpdConfig, runMPD, mpdWait ) where import Plugins.Monitors.Common import System.Console.GetOpt @@ -55,6 +55,10 @@ runMPD args = do s <- parseMPD status song opts parseTemplate s +mpdWait :: IO () +mpdWait = M.withMPD idle >> return () + where idle = M.idle [M.PlayerS, M.MixerS] + mopts :: [String] -> IO MOpts mopts argv = case getOpt Permute options argv of |