diff options
| -rw-r--r-- | init.el | 14 | ||||
| -rw-r--r-- | lib/media/jao-mpc.el | 55 | 
2 files changed, 39 insertions, 30 deletions
| @@ -3046,6 +3046,8 @@    (setq jao-mpc-last-port (unless jao-mpc-last-port jao-mopidy-port)          jao-mpc-port jao-mpc-last-port)) +(defsubst jao-mpc-mopidy-p () (equal jao-mpc-last-port jao-mopidy-port)) +  (jao-mpc-setup jao-mopidy-port (if jao-modeline-in-minibuffer -10 70))  (defun jao-mpc-pport (&optional mop) @@ -3142,7 +3144,12 @@      ("K" "dislike" jao-streaming-dislike)]])  (transient-define-prefix jao-transient-media () -  [["Play" +  [:description +   (lambda () +     (format "[%s   %s]\n" +             (if (jao-mpc-mopidy-p) "mopidy" "mpd") +             (jao-mpc--current-timestr t))) +   ["Play"      ("m" "toggle" jao-player-toggle)      ("n" "next" jao-player-next)      ("p" "previous" jao-player-previous) @@ -3172,10 +3179,7 @@      ("r" (lambda ()             (concat (if jao-random-album-p "dis" "en") "able random album"))       jao-random-album-toggle) -    ("P" (lambda () -           (concat "Toggle to " -                   (if (equal jao-mpc-last-port jao-mopidy-port) -                       "mpd" "mopidy"))) +    ("P" (lambda () (concat "Toggle to " (if (jao-mpc-mopidy-p) "mpd" "mopidy")))       jao-mpc-toggle-port)]])  (global-set-key (kbd "s-m") #'jao-transient-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)) | 
