summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2024-03-27 01:55:20 +0000
committerjao <jao@gnu.org>2024-03-27 01:55:20 +0000
commit36e098007955c45d86269f396203667a0692796a (patch)
tree6a67eb1ff2024546bfa45c4dca3543d1d9a7b3e2 /lib
parent8d9ff7bd76276e454f2dff773a9e9192e44f0ce2 (diff)
downloadelibs-36e098007955c45d86269f396203667a0692796a.tar.gz
elibs-36e098007955c45d86269f396203667a0692796a.tar.bz2
mpc: fixes for next random album trigger
Diffstat (limited to 'lib')
-rw-r--r--lib/media/jao-mpc.el20
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/media/jao-mpc.el b/lib/media/jao-mpc.el
index 4aef47d..70531e1 100644
--- a/lib/media/jao-mpc.el
+++ b/lib/media/jao-mpc.el
@@ -1,6 +1,6 @@
;;; jao-mpc.el --- Using mpc to interact with mpd -*- lexical-binding: t; -*-
-;; Copyright (C) 2021, 2022 jao
+;; Copyright (C) 2021, 2022, 2024 jao
;; Author: jao <mail@jao.io>
;; Keywords: convenience
@@ -117,7 +117,7 @@
(setq jao-mpc-minibuffer-str
(if (string= "playing" status) (jao-mpc--current-str port) ""))
(when (and jao-random-album-active
- (string= status "paused")
+ (or (string= status "stopped") (string= status "paused"))
(string= "0\n" (jao-mpc--cmd "status %songpos%" port)))
(jao-random-album-next)))
(jao-minibuffer-refresh))
@@ -199,15 +199,22 @@
(let ((jao-mpc-port (or port jao-mpc-port))) (jao-mpc-playlist-mode))
(current-buffer)))
+(defun jao-mpc--with-delayed-random-album (cmd port)
+ (let ((st jao-random-album-active))
+ (setq jao-random-album-active nil)
+ (jao-mpc--cmd cmd port)
+ (accept-process-output nil 0.5)
+ (setq jao-random-album-active st)))
+
;;;###autoload
(defun jao-mpc-stop (&optional port)
(interactive)
- (jao-mpc--cmd "stop" port))
+ (jao-mpc--with-delayed-random-album "stop" port))
;;;###autoload
(defun jao-mpc-toggle (&optional port)
(interactive)
- (jao-mpc--cmd "toggle" port))
+ (jao-mpc--with-delayed-random-album "toggle" port))
;;;###autoload
(defun jao-mpc-play (&optional port)
@@ -240,6 +247,11 @@
(message "%s" (jao-mpc--current-str port t)))
;;;###autoload
+(defun jao-mpc-echo-current-times (&optional port)
+ (interactive)
+ (message "Playing time: %s" (jao-mpc--current-timestr t)))
+
+;;;###autoload
(defun jao-mpc-add-url (url)
(interactive "sURL: ")
(jao-mpc--cmd (format "add %s" url)))