summaryrefslogtreecommitdiffhomepage
path: root/src/Plugins
diff options
context:
space:
mode:
authorDuncan Burke <duncankburke@gmail.com>2014-12-14 17:14:49 +1100
committerDuncan Burke <duncankburke@gmail.com>2014-12-15 15:29:58 +1100
commit87c8c13bf4346ba5d4e42684530e6642cdb534ba (patch)
tree5ed246a6632e7671467db53941f3e72a303fb874 /src/Plugins
parent0cae5039d549ee757bcf382c46403335d05aa047 (diff)
downloadxmobar-87c8c13bf4346ba5d4e42684530e6642cdb534ba.tar.gz
xmobar-87c8c13bf4346ba5d4e42684530e6642cdb534ba.tar.bz2
MPD: add a new template variable 'flags'
Displays playback flags in the style of ncmpcpp.
Diffstat (limited to 'src/Plugins')
-rw-r--r--src/Plugins/Monitors/MPD.hs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/Plugins/Monitors/MPD.hs b/src/Plugins/Monitors/MPD.hs
index 5e02587..b54962e 100644
--- a/src/Plugins/Monitors/MPD.hs
+++ b/src/Plugins/Monitors/MPD.hs
@@ -24,7 +24,7 @@ import Control.Concurrent (threadDelay)
mpdConfig :: IO MConfig
mpdConfig = mkMConfig "MPD: <state>"
[ "bar", "vbar", "ipat", "state", "statei", "volume", "length"
- , "lapsed", "remaining", "plength", "ppos", "file"
+ , "lapsed", "remaining", "plength", "ppos", "flags", "file"
, "name", "artist", "composer", "performer"
, "album", "title", "track", "genre"
]
@@ -93,7 +93,7 @@ parseMPD (Right st) song opts = do
bar <- showPercentBar (100 * b) b
vbar <- showVerticalBar (100 * b) b
ipat <- showIconPattern (mLapsedIconPattern opts) b
- return $ [bar, vbar, ipat, ss, si, vol, len, lap, remain, plen, ppos] ++ songData
+ return $ [bar, vbar, ipat, ss, si, vol, len, lap, remain, plen, ppos, flags] ++ songData
where s = M.stState st
ss = show s
si = stateGlyph s opts
@@ -103,6 +103,7 @@ parseMPD (Right st) song opts = do
b = if t > 0 then realToFrac $ p / fromIntegral t else 0
plen = int2str $ M.stPlaylistLength st
ppos = maybe "" (int2str . (+1)) $ M.stSongPos st
+ flags = playbackMode st
stateGlyph :: M.State -> MOpts -> String
stateGlyph s o =
@@ -111,6 +112,14 @@ stateGlyph s o =
M.Paused -> mPaused o
M.Stopped -> mStopped o
+playbackMode :: M.Status -> String
+playbackMode s =
+ concat [if p s then f else "-" |
+ (p,f) <- [(M.stRepeat,"r"),
+ (M.stRandom,"z"),
+ (M.stSingle,"s"),
+ (M.stConsume,"c")]]
+
parseSong :: M.Response (Maybe M.Song) -> Monitor [String]
parseSong (Left _) = return $ repeat ""
parseSong (Right Nothing) = return $ repeat ""