summaryrefslogtreecommitdiffhomepage
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
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.
-rw-r--r--readme.md3
-rw-r--r--src/Plugins/Monitors/MPD.hs13
2 files changed, 13 insertions, 3 deletions
diff --git a/readme.md b/readme.md
index 1176401..a49635f 100644
--- a/readme.md
+++ b/readme.md
@@ -1063,6 +1063,7 @@ more than one battery.
`bar`, `vbar`, `ipat`, `state`, `statei`, `volume`, `length`,
`lapsed`, `remaining`,
`plength` (playlist length), `ppos` (playlist position),
+ `flags` (ncmpcpp-style playback mode),
`name`, `artist`, `composer`, `performer`,
`album`, `title`, `track`, `file`, `genre`
- Default template: `MPD: <state>`
@@ -1070,7 +1071,7 @@ more than one battery.
MPD's specific ones):
Run MPD ["-t",
- "<composer> <title> (<album>) <track>/<plength> <statei> ",
+ "<composer> <title> (<album>) <track>/<plength> <statei> [<flags>]",
"--", "-P", ">>", "-Z", "|", "-S", "><"] 10
### `Mpris1 PlayerName Args RefreshRate`
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 ""