summaryrefslogtreecommitdiffhomepage
path: root/src/Plugins/Monitors
diff options
context:
space:
mode:
authorBen Boeckel <mathstuf@gmail.com>2014-02-05 02:31:47 -0500
committerBen Boeckel <mathstuf@gmail.com>2014-02-05 02:31:47 -0500
commitc81976467d317dd23489603f255fcf75bb043be9 (patch)
treee304a66fbce51abe1705f04a1eb529c586b4daa7 /src/Plugins/Monitors
parentedfc09975829b7610b0b054f8168574e942f4cf1 (diff)
downloadxmobar-c81976467d317dd23489603f255fcf75bb043be9.tar.gz
xmobar-c81976467d317dd23489603f255fcf75bb043be9.tar.bz2
Add a "ready" check to MPD monitors
If the MPD server isn't responsive or the network is down, MPD will no longer block xmobar from doing its job.
Diffstat (limited to 'src/Plugins/Monitors')
-rw-r--r--src/Plugins/Monitors/MPD.hs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/Plugins/Monitors/MPD.hs b/src/Plugins/Monitors/MPD.hs
index 0e5980c..1104608 100644
--- a/src/Plugins/Monitors/MPD.hs
+++ b/src/Plugins/Monitors/MPD.hs
@@ -12,7 +12,7 @@
--
-----------------------------------------------------------------------------
-module Plugins.Monitors.MPD ( mpdConfig, runMPD, mpdWait ) where
+module Plugins.Monitors.MPD ( mpdConfig, runMPD, mpdWait, mpdReady ) where
import Data.List
import Plugins.Monitors.Common
@@ -63,6 +63,17 @@ mpdWait = do
Left _ -> threadDelay 10000000
_ -> return ()
+mpdReady :: [String] -> Monitor Bool
+mpdReady _ = do
+ response <- io $ M.withMPD M.ping
+ case response of
+ Right _ -> return True
+ -- Only cases where MPD isn't responding is an issue; bogus information at
+ -- least won't hold xmobar up.
+ Left M.NoMPD -> return False
+ Left M.TimedOut -> return False
+ Left _ -> return True
+
mopts :: [String] -> IO MOpts
mopts argv =
case getOpt Permute options argv of