From eb6a935a51538ad646a9ef65aab4c4d3cc35e0f3 Mon Sep 17 00:00:00 2001 From: jao Date: Tue, 15 Mar 2022 00:03:29 +0000 Subject: mpris: more flexible notification parser --- lib/media/jao-mpris.el | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/media/jao-mpris.el b/lib/media/jao-mpris.el index 4df83c7..63a5aae 100644 --- a/lib/media/jao-mpris.el +++ b/lib/media/jao-mpris.el @@ -91,7 +91,8 @@ (defvar jao-mpris-track-string "") (defun jao-mpris--get (k &optional l) - (alist-get k (or l jao-mpris--current))) + (when-let (v (alist-get k (or l jao-mpris--current))) + (if (consp v) (car v) v))) (defun jao-mpris--set-current (k v) (when v (setf (alist-get k jao-mpris--current "" t) v))) @@ -116,9 +117,10 @@ (jao--put-face (format "%s" (or track "")) 'jao-themes-f00) (jao--put-face (or title "") 'jao-themes-f01) (jao--put-face (or artist "") 'jao-themes-f11) - (jao--put-face (if album (format " (%s)" album) "") + (jao--put-face (if (and album (not (string-blank-p album))) + (format " (%s)" album) "") 'jao-themes-f01) - (if duration (format " %s" duration) "")))) + (if duration (format " - %s" duration) "")))) (defun jao-mpris--track (&optional info) (let ((info (or info (jao-playerctl--status)))) @@ -153,7 +155,7 @@ (when-let (md (caadr (assoc "Metadata" properties))) (let ((tno (caadr (assoc "xesam:trackNumber" md))) (tlt (caadr (assoc "xesam:title" md))) - (art (caaadr (assoc "xesam:artist" md))) + (art (caadr (assoc "xesam:artist" md))) (alb (caadr (assoc "xesam:album" md))) (len (caadr (assoc "mpris:length" md)))) (jao-mpris--set-current 'track tno) -- cgit v1.2.3