summaryrefslogtreecommitdiffhomepage
path: root/Plugins/Monitors/MPD.hs
diff options
context:
space:
mode:
authorJose A Ortega Ruiz <jao@gnu.org>2010-05-22 01:49:30 +0200
committerJose A Ortega Ruiz <jao@gnu.org>2010-05-22 01:49:30 +0200
commit811aac2944e71e87dc3993df112b85cc8ca71bea (patch)
tree90c7506846da47c41972083ddd659cb826a8aad4 /Plugins/Monitors/MPD.hs
parent907fdbc3d1609275fa4762baad14be22cef0530a (diff)
downloadxmobar-811aac2944e71e87dc3993df112b85cc8ca71bea.tar.gz
xmobar-811aac2944e71e87dc3993df112b85cc8ca71bea.tar.bz2
MPD: new field ppos (playlist position).
Ignore-this: 6df60c780a498f6817876fb0ff8ba367 darcs-hash:20100521234930-748be-f530249e276ff2a886b1b5c68706254079cec540.gz
Diffstat (limited to 'Plugins/Monitors/MPD.hs')
-rw-r--r--Plugins/Monitors/MPD.hs20
1 files changed, 12 insertions, 8 deletions
diff --git a/Plugins/Monitors/MPD.hs b/Plugins/Monitors/MPD.hs
index 72b73d6..d6f8ec6 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"
+ , "lapsed", "plength", "ppos"
, "name", "artist", "composer", "performer"
, "album", "title", "track", "trackno", "file", "genre"
]
@@ -56,16 +56,20 @@ 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] ++ sf)
+parseMPD (Right st) song opts = (b, [ss, si, vol, len, lap, plen, pp] ++ sf)
where s = M.stState st
ss = show s
si = stateGlyph s opts
- vol = int2Str $ M.stVolume st
+ vol = int2str $ M.stVolume st
(lap, len) = (showTime p, showTime t)
(p, t) = M.stTime st
b = if t > 0 then fromIntegral p / fromIntegral t else 0
- plen = int2Str $ M.stPlaylistLength st
+ plen = int2str $ M.stPlaylistLength st
sf = parseSong song
+ pp = case M.stSongPos st of
+ Nothing -> ""
+ Just (M.Pos n) -> int2str $ n + 1
+ Just (M.ID n) -> int2str n
stateGlyph :: M.State -> MOpts -> String
stateGlyph s o =
@@ -80,13 +84,13 @@ parseSong (Right Nothing) = repeat ""
parseSong (Right (Just s)) =
[ M.sgName s, M.sgArtist s, M.sgComposer s, M.sgPerformer s
, M.sgAlbum s, M.sgTitle s, track, trackno, M.sgFilePath s, M.sgGenre s]
- where (track, trackno) = (int2Str t, int2Str tn)
+ where (track, trackno) = (show t, show tn)
(t, tn) = M.sgTrack s
showTime :: Integer -> String
-showTime t = int2Str minutes ++ ":" ++ int2Str seconds
+showTime t = int2str minutes ++ ":" ++ int2str seconds
where minutes = t `div` 60
seconds = t `mod` 60
-int2Str :: (Num a, Ord a) => a -> String
-int2Str x = if x < 10 then '0':sx else sx where sx = show x
+int2str :: (Num a, Ord a) => a -> String
+int2str x = if x < 10 then '0':sx else sx where sx = show x