summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/media/jao-mpris.el15
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