summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2020-08-08 23:37:40 +0100
committerjao <jao@gnu.org>2020-08-08 23:39:39 +0100
commit8e2c3adf49c2157789d840d34cec10efdd7eba4f (patch)
tree901f1bba98a893f608d843ea2fb89bd48fb40b2a /src
parent05672f6110bbf90b27a4533022fc23f2df292d30 (diff)
downloadxmobar-8e2c3adf49c2157789d840d34cec10efdd7eba4f.tar.gz
xmobar-8e2c3adf49c2157789d840d34cec10efdd7eba4f.tar.bz2
Mpris2: accepting Word32 as type for trackNumber
spotifyd is funky that way
Diffstat (limited to 'src')
-rw-r--r--src/Xmobar/Plugins/Monitors/Mpris.hs29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/Xmobar/Plugins/Monitors/Mpris.hs b/src/Xmobar/Plugins/Monitors/Mpris.hs
index 480698c..ee30ad3 100644
--- a/src/Xmobar/Plugins/Monitors/Mpris.hs
+++ b/src/Xmobar/Plugins/Monitors/Mpris.hs
@@ -28,7 +28,8 @@ import qualified DBus.Client as DC
import Control.Arrow ((***))
import Data.Maybe ( fromJust )
import Data.Int ( Int32, Int64 )
-import System.IO.Unsafe (unsafePerformIO)
+import Data.Word ( Word32 )
+import System.IO.Unsafe ( unsafePerformIO )
import Control.Exception (try)
@@ -127,21 +128,25 @@ makeList version md = map getStr (fieldsList version) where
where hh = (n `div` 60) `div` 60
mm = (n `div` 60) `mod` 60
ss = n `mod` 60
+ pInt str v = let num = fromVar v in
+ case str of
+ "mtime" -> formatTime (num `div` 1000)
+ "tracknumber" -> printf "%02d" num
+ "mpris:length" -> formatTime (num `div` 1000000)
+ "xesam:trackNumber" -> printf "%02d" num
+ _ -> (show::Int32 -> String) num
+ pw32 v = printf "%02d" (fromVar v::Word32)
+ plen str v = let num = fromVar v in
+ case str of
+ "mpris:length" -> formatTime (num `div` 1000000)
+ _ -> (show::Int64 -> String) num
getStr str = case lookup str md of
Nothing -> ""
Just v -> case variantType v of
TypeString -> fromVar v
- TypeInt32 -> let num = fromVar v in
- case str of
- "mtime" -> formatTime (num `div` 1000)
- "tracknumber" -> printf "%02d" num
- "mpris:length" -> formatTime (num `div` 1000000)
- "xesam:trackNumber" -> printf "%02d" num
- _ -> (show::Int32 -> String) num
- TypeInt64 -> let num = fromVar v in
- case str of
- "mpris:length" -> formatTime (num `div` 1000000)
- _ -> (show::Int64 -> String) num
+ TypeInt32 -> pInt str v
+ TypeWord32 -> pw32 v
+ TypeInt64 -> plen str v
TypeArray TypeString ->
let x = arrayItems (fromVar v) in
if null x then "" else fromVar (head x)