summaryrefslogtreecommitdiffhomepage
path: root/src/Plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/Plugins')
-rw-r--r--src/Plugins/Monitors.hs5
-rw-r--r--src/Plugins/Monitors/Common.hs9
-rw-r--r--src/Plugins/Monitors/MPD.hs6
3 files changed, 16 insertions, 4 deletions
diff --git a/src/Plugins/Monitors.hs b/src/Plugins/Monitors.hs
index 9f17699..a531e26 100644
--- a/src/Plugins/Monitors.hs
+++ b/src/Plugins/Monitors.hs
@@ -19,7 +19,7 @@ module Plugins.Monitors where
import Plugins
-import Plugins.Monitors.Common ( runM )
+import Plugins.Monitors.Common ( runM, runMB )
import Plugins.Monitors.Weather
import Plugins.Monitors.Net
import Plugins.Monitors.Mem
@@ -71,6 +71,7 @@ data Monitors = Weather Station Args Rate
#endif
#ifdef LIBMPD
| MPD Args Rate
+ | AutoMPD Args
#endif
#ifdef ALSA
| Volume String String Args Rate
@@ -115,6 +116,7 @@ instance Exec Monitors where
#endif
#ifdef LIBMPD
alias (MPD _ _) = "mpd"
+ alias (AutoMPD _) = "autompd"
#endif
#ifdef ALSA
alias (Volume m c _ _) = m ++ ":" ++ c
@@ -147,6 +149,7 @@ instance Exec Monitors where
#endif
#ifdef LIBMPD
start (MPD a r) = runM a mpdConfig runMPD r
+ start (AutoMPD a) = runMB a mpdConfig runMPD mpdWait
#endif
#ifdef ALSA
start (Volume m c a r) = runM a volumeConfig (runVolume m c) r
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