summaryrefslogtreecommitdiffhomepage
path: root/lib/media
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2022-08-27 03:31:47 +0100
committerjao <jao@gnu.org>2022-08-27 03:54:42 +0100
commit40ec9acb94ee96e0afafcddcfb2d4b35b4623ad7 (patch)
tree8283ac796ddee893b82dab5051a46497e63abd75 /lib/media
parentb820b18d7814c5291236d3aed26d34c6fc9c4d8d (diff)
downloadelibs-40ec9acb94ee96e0afafcddcfb2d4b35b4623ad7.tar.gz
elibs-40ec9acb94ee96e0afafcddcfb2d4b35b4623ad7.tar.bz2
mpc: auto-random fixed and nicer transient
Diffstat (limited to 'lib/media')
-rw-r--r--lib/media/jao-mpc.el55
1 files changed, 30 insertions, 25 deletions
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))