diff options
Diffstat (limited to 'media')
-rw-r--r-- | media/jao-emms-info-track.el | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/media/jao-emms-info-track.el b/media/jao-emms-info-track.el index 728666d..d2e2867 100644 --- a/media/jao-emms-info-track.el +++ b/media/jao-emms-info-track.el @@ -57,8 +57,10 @@ "Return track info for streams" (let ((name (emms-track-name track)) (title (or (emms-track-get track 'title nil) - (car (emms-track-get track 'metadata nil))))) - (format "♪ %s (%s)" title (if title (emms-track-type track) name)))) + (car (emms-track-get track 'metadata nil)) + (car (split-string (shell-command-to-string "mpc status") + "\n"))))) + (format "♪ %s (%s)" (or title "") (if title (emms-track-type track) name)))) (defsubst jao--put-face (str face) (put-text-property 0 (length str) 'face face str) @@ -154,33 +156,35 @@ (interactive) (when jao-emms-show-osd-p (jao-emms-show-osd))) -(defun jao-emms-install-i3dv2 () +(defun jao-emms-install-id3v2 () (add-to-list 'emms-tag-editor-tagfile-functions - '("mp3" "id3v2" ((info-artist . "a") - (info-title . "t") - (info-album . "A") - (info-tracknumber . "T") - (info-year . "y") - (info-genre . "g") - (info-composer . "-TCOM") - (info-note . "c"))))) + '("mp3" "id3v2" ((info-artist . "-a") + (info-title . "-t") + (info-album . "-A") + (info-tracknumber . "-T") + (info-year . "-y") + (info-genre . "-g") + (info-composer . "--TCOM") + (info-note . "-c"))))) (defvar jao-emms-echo-string "") + +(defun jao-emms--echo-string (v) + (setq jao-emms-echo-string v) + (jao-minibuffer-refresh)) + (defun jao-emms-update-echo-string (&optional existing-track) (if emms-player-playing-p (jao-emms--with-mpd-track (lambda (track lapsed play-len) - (setq jao-emms-echo-string - (if emms-player-paused-p - (if existing-track - (format "(%s/%s)" - (emms-track-get existing-track 'info-tracknumber) - play-len) - "") - (jao-emms-info-track-description track nil play-len))) - (jao-minibuffer-refresh))) - (setq jao-emms-echo-string "") - (jao-minibuffer-refresh))) + (jao-emms--echo-string + (cond ((and emms-player-paused-p existing-track) + (format "(%s/%s)" + (emms-track-get existing-track 'info-tracknumber) + play-len)) + (emms-player-paused-p "") + (t (jao-emms-info-track-description track nil play-len)))))) + (jao-emms--echo-string ""))) (defun jao-emms-enable-minibuffer () (jao-minibuffer-add-variable 'jao-emms-echo-string t) @@ -192,15 +196,15 @@ (add-hook h #'jao-emms-update-echo-string))) ;;;###autoload -(defun jao-emms-info-setup (&optional show-mini show-osd show-echo-line no-id3) +(defun jao-emms-info-setup (&optional minibuffer show-osd show-echo-line id3) (setq emms-track-description-function 'jao-emms-info-track-description) (setq jao-emms-show-osd-p show-osd) (add-hook 'emms-player-started-hook 'jao-emms-show-osd-hook) - (when show-mini (jao-emms-enable-minibuffer)) + (when minibuffer (jao-emms-enable-minibuffer)) (unless show-echo-line (eval-after-load 'emms-player-mpd '(remove-hook 'emms-player-started-hook 'emms-player-mpd-show))) - (unless no-id3 (jao-emms-install-i3dv2)) + (when id3 (jao-emms-install-id3v2)) (ignore-errors (emms-player-mpd-connect))) |