From 40ec9acb94ee96e0afafcddcfb2d4b35b4623ad7 Mon Sep 17 00:00:00 2001 From: jao Date: Sat, 27 Aug 2022 03:31:47 +0100 Subject: mpc: auto-random fixed and nicer transient --- lib/media/jao-mpc.el | 55 ++++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 25 deletions(-) (limited to 'lib/media') diff --git a/lib/media/jao-mpc.el b/lib/media/jao-mpc.el index b2fbce2..88cde6f 100644 --- a/lib/media/jao-mpc.el +++ b/lib/media/jao-mpc.el @@ -77,30 +77,35 @@ (put-text-property 0 (length str) 'face face str) str) +(defun jao-mpc--current-timestr (times &optional current) + (let* ((current (or current (jao-mpc--current))) + (time (alist-get 'totaltime current ""))) + (if times + (format "%s/%s%s" + (alist-get 'currenttime current "") + time + (alist-get 'percenttime current "")) + (format "%s" time)))) + (defun jao-mpc--current-str (&optional port times) - (let* ((current (jao-mpc--current port)) - (len (alist-get 'length current "0")) - (title (alist-get 'title current (alist-get 'name current ""))) - (album (alist-get 'album current)) - (artist (alist-get 'artist current)) - (composer (alist-get 'composer current)) - (no (string-to-number (alist-get 'songpos current "0"))) - (time (alist-get 'totaltime current "")) - (tims (if times - (format " [%s/%s%s]" - (alist-get 'currenttime current "") - time - (alist-get 'percenttime current "")) - (format " [%s]" time)))) - (format "%s%s %s%s%s%s" ;;  - (jao--put-face (if (zerop no) "" (format "%02d/%s " no len)) - 'jao-themes-f02) - (jao--put-face (or title "") 'jao-themes-f00) - (jao--put-face (or artist "") 'jao-themes-f01) - (jao--put-face (if composer (format " [%s]" composer) "") - 'jao-themes-f01) - (jao--put-face (if album (format " (%s)" album) "") 'jao-themes-f11) - (jao--put-face tims (if times 'jao-themes-f00 'jao-themes-dimm))))) + (if-let* ((current (jao-mpc--current port)) + (title (alist-get 'title current (alist-get 'name current)))) + (let ((len (alist-get 'length current "0")) + (album (alist-get 'album current)) + (artist (alist-get 'artist current)) + (composer (alist-get 'composer current)) + (no (string-to-number (alist-get 'songpos current "0"))) + (tims (concat " [" (jao-mpc--current-timestr times current) "]"))) + (format "%s%s %s%s%s%s" ;;  + (jao--put-face (if (zerop no) "" (format "%02d/%s " no len)) + 'jao-themes-f02) + (jao--put-face (or title "") 'jao-themes-f00) + (jao--put-face (or artist "") 'jao-themes-f01) + (jao--put-face (if composer (format " [%s]" composer) "") + 'jao-themes-f01) + (jao--put-face (if album (format " (%s)" album) "") 'jao-themes-f11) + (jao--put-face tims (if times 'jao-themes-f00 'jao-themes-dimm)))) + "")) (defvar jao-mpc-minibuffer-str "") @@ -108,8 +113,8 @@ (setq jao-mpc-minibuffer-str (if (jao-mpc--playing-p port) (jao-mpc--current-str port) - (when (and (null port) jao-random-album-p (not (jao-mpc--current))) - (jao-random-album-next)) + (when (and jao-random-album-p (not (jao-mpc--current-str port))) + (let ((inhibit-message t)) (jao-random-album-next))) "")) (jao-minibuffer-refresh)) -- cgit v1.2.3