diff options
author | jao <jao@gnu.org> | 2022-01-30 08:00:51 +0000 |
---|---|---|
committer | jao <jao@gnu.org> | 2022-01-30 08:00:51 +0000 |
commit | 6cd287823401747e5716e203864a387aa762c18c (patch) | |
tree | b15291472bb707cbd2da87b8bab535348cad1705 /lib | |
parent | fe17687ca528a8d8526f40e8ba895cf48800e803 (diff) | |
download | elibs-6cd287823401747e5716e203864a387aa762c18c.tar.gz elibs-6cd287823401747e5716e203864a387aa762c18c.tar.bz2 |
mpris clean-ups, and, oh, spotify -> streaming
Diffstat (limited to 'lib')
-rw-r--r-- | lib/media/jao-mpris.el | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/lib/media/jao-mpris.el b/lib/media/jao-mpris.el index d34480a..c9f917a 100644 --- a/lib/media/jao-mpris.el +++ b/lib/media/jao-mpris.el @@ -90,6 +90,9 @@ (defun jao-mpris--get (k &optional l) (alist-get k (or l jao-mpris--current))) +(defun jao-mpris--set-current (k v) + (setf (alist-get k jao-mpris--current "" t) v)) + (defun jao-mpris--fmt-time (x suffix) (if x (format "%02d:%02d%s" (/ x 60) (mod x 60) (or suffix "")) "")) @@ -138,26 +141,22 @@ (jao-minibuffer-add-variable 'jao-mpris-track-string order))) (defun jao-mpris--handler (_iname properties &rest _args) - (when properties - (let ((st (caadr (assoc "PlaybackStatus" properties))) - (md (caadr (assoc "Metadata" properties)))) - (cond ((and st (not (string= "Playing" st))) - (setq jao-mpris-track-string "") - (setq jao-mpris--current - (cons (cons 'status st) - (assq-delete-all 'status jao-mpris--current))) - (jao-minibuffer-refresh) - (message "Music %s" st)) - (md (let ((tno (caadr (assoc "xesam:trackNumber" md))) - (tlt (caadr (assoc "xesam:title" md))) - (art (caaadr (assoc "xesam:artist" md))) - (alb (caadr (assoc "xesam:album" md))) - (len (caadr (assoc "mpris:length" md)))) - (setq jao-mpris--current - `((track . ,tno) (title . ,tlt) - (artist . ,art) (album . ,alb) - (length . ,len) (status . ,st))) - (jao-mpris--track jao-mpris--current))))))) + (let ((inhibit-message t)) + (message "Receivied properties: %S from %s" properties _iname)) + (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))) + (alb (caadr (assoc "xesam:album" md))) + (len (caadr (assoc "mpris:length" md)))) + (jao-mpris--set-current 'track tno) + (jao-mpris--set-current 'title tlt) + (jao-mpris--set-current 'artist art) + (jao-mpris--set-current 'album alb) + (jao-mpris--set-current 'length len))) + (when-let (st (caadr (assoc "PlaybackStatus" properties))) + (jao-mpris--set-current 'status st)) + (jao-mpris--track jao-mpris--current)) ;;;###autoload (defun jao-mpris-register (name &optional bus order) |