summaryrefslogtreecommitdiffhomepage
path: root/src/Plugins/Monitors/Mpris.hs
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2016-04-30 21:17:26 +0200
committerjao <jao@gnu.org>2016-04-30 21:17:26 +0200
commit37189a6f08edc8391a2cde776b733b92b8b3943c (patch)
tree59f9838b2aa9f23cfe0e9802835221d50bfeefee /src/Plugins/Monitors/Mpris.hs
parentd2b16c9b7fb1507aff44f301fef9109320895456 (diff)
downloadxmobar-37189a6f08edc8391a2cde776b733b92b8b3943c.tar.gz
xmobar-37189a6f08edc8391a2cde776b733b92b8b3943c.tar.bz2
Fix for empty metadata in MPris calls
Diffstat (limited to 'src/Plugins/Monitors/Mpris.hs')
-rw-r--r--src/Plugins/Monitors/Mpris.hs19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/Plugins/Monitors/Mpris.hs b/src/Plugins/Monitors/Mpris.hs
index 245c0df..05718cf 100644
--- a/src/Plugins/Monitors/Mpris.hs
+++ b/src/Plugins/Monitors/Mpris.hs
@@ -99,12 +99,15 @@ fromVar = fromJust . fromVariant
unpackMetadata :: [Variant] -> [(String, Variant)]
unpackMetadata [] = []
-unpackMetadata xs = (map (fromVar *** fromVar) . unpack . head) xs where
- unpack v = case variantType v of
- TypeDictionary _ _ -> dictionaryItems $ fromVar v
- TypeVariant -> unpack $ fromVar v
- TypeStructure _ -> unpack $ head $ structureItems $ fromVar v
- _ -> []
+unpackMetadata xs =
+ (map (fromVar *** fromVar) . unpack . head) xs where
+ unpack v = case variantType v of
+ TypeDictionary _ _ -> dictionaryItems $ fromVar v
+ TypeVariant -> unpack $ fromVar v
+ TypeStructure _ ->
+ let x = structureItems (fromVar v) in
+ if x == [] then [] else unpack (head x)
+ _ -> []
getMetadata :: (MprisVersion a) => a -> DC.Client -> String -> IO [(String, Variant)]
getMetadata version client player = do
@@ -136,5 +139,7 @@ makeList version md = map getStr (fieldsList version) where
case str of
"mpris:length" -> formatTime (num `div` 1000000)
_ -> (show::Int64 -> String) num
- TypeArray TypeString -> fromVar $ head $ arrayItems $ fromVar v
+ TypeArray TypeString ->
+ let x = arrayItems (fromVar v) in
+ if x == [] then "" else fromVar (head x)
_ -> ""