summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2019-11-13 23:49:52 +0000
committerjao <jao@gnu.org>2019-11-14 00:35:46 +0000
commit6150993d0528b2a081b3d7e0b7e76732a611625d (patch)
tree7a7f914d61db6da89017f14eb386b3556c2ac397 /src/Xmobar
parent74df93eaa2da360af6593fe473698d211370de15 (diff)
downloadxmobar-6150993d0528b2a081b3d7e0b7e76732a611625d.tar.gz
xmobar-6150993d0528b2a081b3d7e0b7e76732a611625d.tar.bz2
MPD monitor: host and port specifiable in config
Diffstat (limited to 'src/Xmobar')
-rw-r--r--src/Xmobar/Plugins/Monitors/MPD.hs18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/Xmobar/Plugins/Monitors/MPD.hs b/src/Xmobar/Plugins/Monitors/MPD.hs
index b6d154a..cd08cda 100644
--- a/src/Xmobar/Plugins/Monitors/MPD.hs
+++ b/src/Xmobar/Plugins/Monitors/MPD.hs
@@ -34,6 +34,8 @@ data MOpts = MOpts
, mStopped :: String
, mPaused :: String
, mLapsedIconPattern :: Maybe IconPattern
+ , mPort :: Maybe String
+ , mHost :: Maybe String
}
defaultOpts :: MOpts
@@ -42,6 +44,8 @@ defaultOpts = MOpts
, mStopped = "><"
, mPaused = "||"
, mLapsedIconPattern = Nothing
+ , mPort = Nothing
+ , mHost = Nothing
}
options :: [OptDescr (MOpts -> MOpts)]
@@ -49,15 +53,20 @@ options =
[ Option "P" ["playing"] (ReqArg (\x o -> o { mPlaying = x }) "") ""
, Option "S" ["stopped"] (ReqArg (\x o -> o { mStopped = x }) "") ""
, Option "Z" ["paused"] (ReqArg (\x o -> o { mPaused = x }) "") ""
+ , Option "p" ["port"] (ReqArg (\x o -> o { mPort = Just x }) "") ""
+ , Option "h" ["host"] (ReqArg (\x o -> o { mHost = Just x }) "") ""
, Option "" ["lapsed-icon-pattern"] (ReqArg (\x o ->
o { mLapsedIconPattern = Just $ parseIconPattern x }) "") ""
]
+withMPD :: MOpts -> M.MPD a -> IO (M.Response a)
+withMPD opts = M.withMPD_ (mHost opts) (mPort opts)
+
runMPD :: [String] -> Monitor String
runMPD args = do
opts <- io $ mopts args
- status <- io $ M.withMPD M.status
- song <- io $ M.withMPD M.currentSong
+ status <- io $ withMPD opts M.status
+ song <- io $ withMPD opts M.currentSong
s <- parseMPD status song opts
parseTemplate s
@@ -69,8 +78,9 @@ mpdWait = do
_ -> return ()
mpdReady :: [String] -> Monitor Bool
-mpdReady _ = do
- response <- io $ M.withMPD M.ping
+mpdReady args = do
+ opts <- io $ mopts args
+ response <- io $ withMPD opts M.ping
case response of
Right _ -> return True
-- Only cases where MPD isn't responding is an issue; bogus information at