From 36e098007955c45d86269f396203667a0692796a Mon Sep 17 00:00:00 2001 From: jao Date: Wed, 27 Mar 2024 01:55:20 +0000 Subject: mpc: fixes for next random album trigger --- lib/media/jao-mpc.el | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'lib') 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 ;; 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) @@ -239,6 +246,11 @@ (interactive) (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: ") -- cgit v1.2.3