summaryrefslogtreecommitdiffhomepage
path: root/Plugins/Monitors
diff options
context:
space:
mode:
authorJose A Ortega Ruiz <jao@gnu.org>2010-10-02 03:54:15 +0200
committerJose A Ortega Ruiz <jao@gnu.org>2010-10-02 03:54:15 +0200
commit0310c0b24ca508a70d2e276c96898d76aed7c7ea (patch)
tree3718663292c654907c651e82de0754d805b312e0 /Plugins/Monitors
parentc58603e60eb8673e02ed8cbdd7ff0b668f6de0ad (diff)
downloadxmobar-0310c0b24ca508a70d2e276c96898d76aed7c7ea.tar.gz
xmobar-0310c0b24ca508a70d2e276c96898d76aed7c7ea.tar.bz2
MPD refactoring
Ignore-this: 41e26c0538bf4a4e78dceda558db5011 darcs-hash:20101002015415-748be-087e42a5001aa030762c0c6a7da13c19c48b602b.gz
Diffstat (limited to 'Plugins/Monitors')
-rw-r--r--Plugins/Monitors/MPD.hs20
1 files changed, 7 insertions, 13 deletions
diff --git a/Plugins/Monitors/MPD.hs b/Plugins/Monitors/MPD.hs
index 250fd47..34f409c 100644
--- a/Plugins/Monitors/MPD.hs
+++ b/Plugins/Monitors/MPD.hs
@@ -21,9 +21,9 @@ import qualified Network.MPD as M
mpdConfig :: IO MConfig
mpdConfig = mkMConfig "MPD: <state>"
[ "bar", "state", "statei", "volume", "length"
- , "lapsed", "remaining", "plength", "ppos"
+ , "lapsed", "remaining", "plength", "ppos", "file"
, "name", "artist", "composer", "performer"
- , "album", "title", "track", "file", "genre"
+ , "album", "title", "track", "genre"
]
data MOpts = MOpts
@@ -100,17 +100,11 @@ parseSong :: M.Response (Maybe M.Song) -> [String]
parseSong (Left _) = repeat ""
parseSong (Right Nothing) = repeat ""
parseSong (Right (Just s)) =
- [name, artist, composer, performer , album, title, track, path, 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
- path = M.sgFilePath s
+ M.sgFilePath s : map str [ M.Name, M.Artist, M.Composer, M.Performer
+ , M.Album, M.Title, M.Track, M.Genre ]
+ where join [] = ""
+ join (x:xs) = foldl (\a o -> a ++ ", " ++ o) x xs
+ str sel = maybe "" join (M.sgGet sel s)
showTime :: Integer -> String
showTime t = int2str minutes ++ ":" ++ int2str seconds