summaryrefslogtreecommitdiffhomepage
path: root/emms
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2019-09-25 23:54:55 +0100
committerjao <jao@gnu.org>2019-09-25 23:54:55 +0100
commit2d66336348e00733614a0f30d38178fcd61a5993 (patch)
tree459d8554ce9717210ba895ea68938e87955d1cb8 /emms
parentfe7f5ac92bb9dfb4dd89f0e3e018cde6d15c8608 (diff)
downloadelibs-2d66336348e00733614a0f30d38178fcd61a5993.tar.gz
elibs-2d66336348e00733614a0f30d38178fcd61a5993.tar.bz2
better notifications for mpd tracks
Diffstat (limited to 'emms')
-rw-r--r--emms/jao-emms-info-track.el34
1 files changed, 22 insertions, 12 deletions
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)