summaryrefslogtreecommitdiffhomepage
path: root/Plugins/Monitors
diff options
context:
space:
mode:
authorJose A Ortega Ruiz <jao@gnu.org>2010-09-27 22:34:28 +0200
committerJose A Ortega Ruiz <jao@gnu.org>2010-09-27 22:34:28 +0200
commitd538b36923c3bc9fcefdb97328daf9fe19c87212 (patch)
tree11bc6b35f678fb74a7315ed2ac3e7b52bc2c06c5 /Plugins/Monitors
parentb45170cb750309e3b60e4b8ce5d65230d8842d97 (diff)
downloadxmobar-d538b36923c3bc9fcefdb97328daf9fe19c87212.tar.gz
xmobar-d538b36923c3bc9fcefdb97328daf9fe19c87212.tar.bz2
MPD plugin updated to use libmpd 0.5
Ignore-this: b66ea532da0c3cc49d6c03a29a5bbc42 darcs-hash:20100927203428-748be-ac1c0a63c653e88c9c9c61958fc4f7f65f9b992c.gz
Diffstat (limited to 'Plugins/Monitors')
-rw-r--r--Plugins/Monitors/MPD.hs26
1 files changed, 17 insertions, 9 deletions
diff --git a/Plugins/Monitors/MPD.hs b/Plugins/Monitors/MPD.hs
index d2ffa15..d5da794 100644
--- a/Plugins/Monitors/MPD.hs
+++ b/Plugins/Monitors/MPD.hs
@@ -57,19 +57,19 @@ 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, remain, plen, pp] ++ parseSong song)
+ (realToFrac b, [ss, si, vol, len, lap, remain, plen, pp] ++ parseSong song)
where s = M.stState st
ss = show s
si = stateGlyph s opts
vol = int2str $ M.stVolume st
(p, t) = M.stTime st
- [lap, len, remain] = map showTime [p, t, max 0 (t - p)]
- b = if t > 0 then fromIntegral p / fromIntegral t else 0
+ ps = floor p
+ [lap, len, remain] = map showTime [ps, t, max 0 (t - ps)]
+ b = if t > 0 then p / fromIntegral t else 0
plen = int2str $ M.stPlaylistLength st
pp = case M.stSongPos st of
Nothing -> ""
- Just (M.Pos n) -> int2str $ n + 1
- Just (M.ID n) -> int2str n
+ Just n -> int2str $ n + 1
stateGlyph :: M.State -> MOpts -> String
stateGlyph s o =
@@ -82,10 +82,18 @@ parseSong :: M.Response (Maybe M.Song) -> [String]
parseSong (Left _) = repeat ""
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) = (show t, show tn)
- (t, tn) = M.sgTrack s
+ [ name, artist, composer, performer , album, title
+ , track, trackno, M.sgFilePath s, genre]
+ where str sel = maybe "" head (M.sgGet sel s)
+ name = str M.Name
+ artist = str M.Artist
+ composer = str M.Composer
+ performer = str M.Performer
+ album = str M.Album
+ title = str M.Title
+ genre = str M.Genre
+ track = str M.Track
+ trackno = track
showTime :: Integer -> String
showTime t = int2str minutes ++ ":" ++ int2str seconds