From 2d66336348e00733614a0f30d38178fcd61a5993 Mon Sep 17 00:00:00 2001 From: jao Date: Wed, 25 Sep 2019 23:54:55 +0100 Subject: better notifications for mpd tracks --- emms/jao-emms-info-track.el | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'emms/jao-emms-info-track.el') diff --git a/emms/jao-emms-info-track.el b/emms/jao-emms-info-track.el index 04f4784..92eac7b 100644 --- a/emms/jao-emms-info-track.el +++ b/emms/jao-emms-info-track.el @@ -62,7 +62,7 @@ (put-text-property 0 (length str) 'face face str) str) -(defun jao-emms-info-track-file (track) +(defun jao-emms-info-track-file (track &optional lapsed titlesep) "Return a description of the current track." (let ((no (string-to-number (emms-track-get track 'info-tracknumber "0"))) (time (emms-track-get track 'info-playing-time)) @@ -74,37 +74,47 @@ (play-count (or (emms-track-get track 'play-count) 0))) (if (or (not title) (not album)) (emms-track-simple-description track) - (format "♪ %s%s%s%s%s %s" - (if time (format "[%02d:%02d] " (/ time 60) (mod time 60)) "") + (format "♪ [%s%s] %s%s%s%s%s%s" + (if lapsed (format "%02d:%02d/" (/ lapsed 60) (mod lapsed 60)) "") + (if time (format "%02d:%02d" (/ time 60) (mod time 60)) "") (jao--put-face artist 'jao-emms-font-lock-artist) (jao--put-face (if composer (format " [%s]" composer) "") 'jao-emms-font-lock-artist) (jao--put-face (if album (format " (%s)" album) " *") 'jao-emms-font-lock-album) - (jao--put-face (if (zerop no) "" (format " %02d." no)) + (or titlesep " ") + (jao--put-face (if (zerop no) "" (format " %02d · " no)) 'jao-emms-font-lock-track) (jao--put-face title 'jao-emms-font-lock-title))))) -(defun jao-emms-info-track-description (track) +(defun jao-emms-info-track-description (track &optional lapsed tsep) (if (memq (emms-track-type track) '(streamlist url)) (jao-emms-info-track-stream track) - (jao-emms-info-track-file track))) + (jao-emms-info-track-file track lapsed tsep))) (defun jao-emms-toggle-osd () (interactive) (setq jao-emms-show-osd-p (not jao-emms-show-osd-p)) (message "Emms OSD %s" (if jao-emms-show-osd-p "enabled" "disabled"))) -(defsubst jao-emms-current-track-str () - (substring-no-properties (jao-emms-info-track-description - (emms-playlist-current-selected-track)))) +(defsubst jao-emms-current-track-str (&optional lapsed tsep) + (substring-no-properties + (jao-emms-info-track-description (emms-playlist-current-selected-track) + lapsed tsep))) + +(defvar jao-emms-show-icon nil) (defun jao-emms-show-osd () (interactive) - (let ((str (jao-emms-current-track-str))) - (when str (jao-notify (substring str 2))) - t)) + (emms-player-mpd-get-playing-time + nil + (lambda (v l) + (let* ((sep "~~~~~") + (s (substring (jao-emms-current-track-str l sep) 2)) + (cs (split-string s sep))) + (jao-notify (cadr cs) (car cs) jao-emms-show-icon)) + t))) (defun jao-emms-show-osd-hook () (interactive) -- cgit v1.2.3