diff options
Diffstat (limited to 'lib/media')
-rw-r--r-- | lib/media/jao-mpc.el | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/media/jao-mpc.el b/lib/media/jao-mpc.el index 88cde6f..9cdd5bd 100644 --- a/lib/media/jao-mpc.el +++ b/lib/media/jao-mpc.el @@ -67,10 +67,13 @@ (jao-mpc--parse-fields s res) (jao-mpc--parse-fields st res))) -(defun jao-mpc--playing-p (&optional port) - (string-prefix-p "playing" (jao-mpc--cmd "status %state%" port))) +(defsubst jao-mpc-status (&optional port) + (string-trim (jao-mpc--cmd "status %state%" port))) -(defun jao-mpc--queue-len (&optional port) +(defsubst jao-mpc-playing-p (&optional port) + (string-prefix-p "playing" (jao-mpc-status port))) + +(defsubst jao-mpc--queue-len (&optional port) (string-to-number (jao-mpc--cmd "status %length%" port))) (defsubst jao--put-face (str face) @@ -110,12 +113,13 @@ (defvar jao-mpc-minibuffer-str "") (defun jao-mpc--set-current-str (&optional port) - (setq jao-mpc-minibuffer-str - (if (jao-mpc--playing-p port) - (jao-mpc--current-str port) - (when (and jao-random-album-p (not (jao-mpc--current-str port))) - (let ((inhibit-message t)) (jao-random-album-next))) - "")) + (let ((status (or (jao-mpc-status port) ""))) + (setq jao-mpc-minibuffer-str + (if (string= "playing" status) (jao-mpc--current-str port) "")) + (when (and jao-random-album-p + (string= status "paused") + (string= "0\n" (jao-mpc--cmd "status %songpos%" port))) + (jao-random-album-next))) (jao-minibuffer-refresh)) (defvar jao-mpc--idle-procs nil) @@ -288,7 +292,7 @@ (defun jao-mpc-connect (&optional port) (interactive) (jao-mpc--idle-loop port) - (when (jao-mpc--playing-p port) (jao-mpc--set-current-str port))) + (when (jao-mpc-playing-p port) (jao-mpc--set-current-str port))) ;;;###autoload (defun jao-mpc-setup (&optional secondary-port priority) |