diff options
author | jao <jao@gnu.org> | 2022-02-09 05:33:07 +0000 |
---|---|---|
committer | jao <jao@gnu.org> | 2022-02-09 05:33:07 +0000 |
commit | 59443f92027364d9542a12df7faf7aede82f4be5 (patch) | |
tree | fcedc655d52862cd28ec55d6f4cf22701ede38b1 /lib | |
parent | 9bb5a52f04d6a0ecc47813d011ebc4f4f5b27d2a (diff) | |
download | elibs-59443f92027364d9542a12df7faf7aede82f4be5.tar.gz elibs-59443f92027364d9542a12df7faf7aede82f4be5.tar.bz2 |
mpris nits
Diffstat (limited to 'lib')
-rw-r--r-- | lib/media/jao-mpris.el | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/media/jao-mpris.el b/lib/media/jao-mpris.el index 08b405a..977dab3 100644 --- a/lib/media/jao-mpris.el +++ b/lib/media/jao-mpris.el @@ -28,7 +28,7 @@ (require 'jao-themes) (require 'jao-minibuffer) -(defvar jao-mpris-player "chromium") +(defvar jao-mpris-player "playerctld") (defun jao-mpris--playerctl (&rest args) (shell-command-to-string (format "playerctl -p %s %s" @@ -96,6 +96,9 @@ (defun jao-mpris--set-current (k v) (when v (setf (alist-get k jao-mpris--current "" t) v))) +(defun jao-mpris--del-current (k) + (setf (alist-get k jao-mpris--current "" t) "")) + (defun jao-mpris--fmt-time (x suffix) (if x (format "%02d:%02d%s" (/ x 60) (mod x 60) (or suffix "")) "")) @@ -130,8 +133,9 @@ (cons (jao-mpris--get 'artist) (jao-mpris--get 'title)))) ;;;###autoload -(defun jao-mpris-show-osd () - (interactive) +(defun jao-mpris-show-osd (&optional refresh) + (interactive "P") + (when refresh (jao-mpris--track)) (when jao-mpris--current (jao-notify (format "%s%s" (if-let (s (jao-mpris--get 'status)) (format "%s: " s) @@ -158,7 +162,10 @@ (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--set-current 'status st) + (when (string= st "Stopped") + (dolist (k '(track title artist album length)) + (jao-mpris--del-current k)))) (jao-mpris--track jao-mpris--current)) ;;;###autoload |