summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJose A Ortega Ruiz <jao@gnu.org>2010-05-30 15:26:42 +0200
committerJose A Ortega Ruiz <jao@gnu.org>2010-05-30 15:26:42 +0200
commitdda166d42608f2170dd3af14a1a28e82941429fd (patch)
tree9f71d53b16a79896b49a6dc34265c724a76ff504
parentd89e78b8e254bb0c2b1597d85998b49754849113 (diff)
downloadxmobar-dda166d42608f2170dd3af14a1a28e82941429fd.tar.gz
xmobar-dda166d42608f2170dd3af14a1a28e82941429fd.tar.bz2
New MPD field: remaining time.
Ignore-this: 26930a015637cf0b4bb86e5c84409654 darcs-hash:20100530132642-748be-b1baa3fa98907c333733134c56cb6cd29625181f.gz
-rw-r--r--Plugins/Monitors/MPD.hs8
-rw-r--r--README3
2 files changed, 7 insertions, 4 deletions
diff --git a/Plugins/Monitors/MPD.hs b/Plugins/Monitors/MPD.hs
index d6f8ec6..520279f 100644
--- a/Plugins/Monitors/MPD.hs
+++ b/Plugins/Monitors/MPD.hs
@@ -21,7 +21,7 @@ import qualified Network.MPD as M
mpdConfig :: IO MConfig
mpdConfig = mkMConfig "MPD: <state>"
[ "bar", "state", "statei", "volume", "length"
- , "lapsed", "plength", "ppos"
+ , "lapsed", "remaining", "plength", "ppos"
, "name", "artist", "composer", "performer"
, "album", "title", "track", "trackno", "file", "genre"
]
@@ -56,13 +56,15 @@ mopts argv =
parseMPD :: M.Response M.Status -> M.Response (Maybe M.Song) -> MOpts
-> (Float, [String])
parseMPD (Left e) _ _ = (0, show e:repeat "")
-parseMPD (Right st) song opts = (b, [ss, si, vol, len, lap, plen, pp] ++ sf)
+parseMPD (Right st) song opts =
+ (b, [ss, si, vol, len, lap, remain, plen, pp] ++ sf)
where s = M.stState st
ss = show s
si = stateGlyph s opts
vol = int2str $ M.stVolume st
- (lap, len) = (showTime p, showTime t)
(p, t) = M.stTime st
+ (lap, len) = (showTime p, showTime t)
+ remain = showTime $ max 0 (t - p)
b = if t > 0 then fromIntegral p / fromIntegral t else 0
plen = int2str $ M.stPlaylistLength st
sf = parseSong song
diff --git a/README b/README
index d0c710f..0375269 100644
--- a/README
+++ b/README
@@ -451,7 +451,8 @@ Monitors have default aliases.
playing, stopped and paused states in the `statei` template field.
- Variables that can be used with the `-t`/`--template` argument:
`bar`, `state`, `statei`, `volume`, `length`
- `lapsed`, `plength` (playlist length), `ppos` (playlist position)
+ `lapsed`, `remaining`,
+ `plength` (playlist length), `ppos` (playlist position)
`name`, `artist`, `composer`, `performer`
`album`, `title`, `track`, `file`, `genre`
- Default template: `MPD: <state>`