summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2014-02-05 01:55:30 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2014-02-05 01:55:30 +0100
commit14480f667cf129808d7732e36cdeee0a27c95624 (patch)
tree6b1138546035f4be47d08ae95d3ce84522091c70
parenta7f0be94f66210ad1f70f0e101050dd5e5cabfc9 (diff)
downloadxmobar-14480f667cf129808d7732e36cdeee0a27c95624.tar.gz
xmobar-14480f667cf129808d7732e36cdeee0a27c95624.tar.bz2
Fix for infinite loops when MPD is not running
Should address #76 and #111.
-rw-r--r--news.md4
-rw-r--r--src/Plugins/Monitors/MPD.hs9
2 files changed, 11 insertions, 2 deletions
diff --git a/news.md b/news.md
index 55b2dff..414b529 100644
--- a/news.md
+++ b/news.md
@@ -5,6 +5,7 @@
_Bug fixes_
- Fix for `Memory` monitor in 3.14 kernels (Ben Boeckel).
+ - Fix for infinite loops in `AutoMPD` ([issue #76], [issue #111]).
- More robust AC readings in `BatteryP`.
- Fix for `Top` monitor's readings for processes whose name contains
blanks.
@@ -12,6 +13,9 @@ _Bug fixes_
- Fixes for missing XDG configuration (Thiago Negri and James McCoy).
- Compatibility with latest `directory` (1.2.0.2).
+[issue #76]: https://github.com/jaor/xmobar/issues/76
+[issue #111]: https://github.com/jaor/xmobar/issues/111
+
## Version 0.19 (October 27, 2013)
As of this release, the old bug tracker at Google code is deprecated.
diff --git a/src/Plugins/Monitors/MPD.hs b/src/Plugins/Monitors/MPD.hs
index 96a8f1d..b57924c 100644
--- a/src/Plugins/Monitors/MPD.hs
+++ b/src/Plugins/Monitors/MPD.hs
@@ -18,6 +18,7 @@ import Data.List
import Plugins.Monitors.Common
import System.Console.GetOpt
import qualified Network.MPD as M
+import Control.Concurrent (threadDelay)
mpdConfig :: IO MConfig
mpdConfig = mkMConfig "MPD: <state>"
@@ -57,7 +58,11 @@ runMPD args = do
parseTemplate s
mpdWait :: IO ()
-mpdWait = M.withMPD idle >> return ()
+mpdWait = do
+ status <- M.withMPD M.status
+ case status of
+ Left _ -> threadDelay 10000000
+ _ -> M.withMPD idle >> return ()
where idle = M.idle [M.PlayerS, M.MixerS]
mopts :: [String] -> IO MOpts
@@ -68,7 +73,7 @@ mopts argv =
parseMPD :: M.Response M.Status -> M.Response (Maybe M.Song) -> MOpts
-> Monitor [String]
-parseMPD (Left e) _ _ = return $ show e:repeat ""
+parseMPD (Left e) _ _ = return $ show e:replicate 18 ""
parseMPD (Right st) song opts = do
songData <- parseSong song
bar <- showPercentBar (100 * b) b