aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--emms-lyrics.el71
-rw-r--r--emms-volume-amixer.el37
2 files changed, 66 insertions, 42 deletions
diff --git a/emms-lyrics.el b/emms-lyrics.el
index 22bfa13..54a7417 100644
--- a/emms-lyrics.el
+++ b/emms-lyrics.el
@@ -114,6 +114,7 @@ at time-i, display lyric-i.")
(defvar emms-lyrics-mode-line-string ""
"current lyric.")
+(defvar emms-lyrics-find-lyric-function nil)
(defun emms-lyrics-read-file (file)
"Read a lyric file(LRC format).
FILE should end up with \".lrc\", its content looks like one of the
@@ -125,38 +126,39 @@ following:
FILE should be under the same directory as the music file, or under
`emms-lyrics-dir'."
- (when (eq 'file (emms-track-get
- (emms-playlist-current-selected-track)
- 'type))
- (unless (file-exists-p file)
- (setq file (emms-lyrics-find-lyric file)))
- (when (and file (not (string= file "")) (file-exists-p file))
- (with-temp-buffer
- (let ((coding-system-for-read emms-lyrics-coding-system))
- (insert-file-contents file)
- (while (search-forward-regexp "\\[[0-9:.]+\\].*" nil t)
- (let ((lyric-string (match-string 0))
- (time 0)
- (lyric ""))
- (setq lyric
- (emms-replace-regexp-in-string ".*\\]" "" lyric-string))
- (while (string-match "\\[[0-9:.]+\\]" lyric-string)
- (let* ((time-string (match-string 0 lyric-string))
- (semi-pos (string-match ":" time-string)))
- (setq time
- (+ (* (string-to-number
- (substring time-string 1 semi-pos))
- 60)
- (string-to-number
- (substring time-string
- (1+ semi-pos)
- (1- (length time-string))))))
- (setq lyric-string
- (substring lyric-string (length time-string)))
- (setq emms-lyrics-alist
- (append emms-lyrics-alist `((,time ,lyric))))
- (setq time 0))))))
- t))))
+ (if (eq 'file (emms-track-get
+ (emms-playlist-current-selected-track)
+ 'type))
+ (unless (file-exists-p file)
+ (setq file (emms-lyrics-find-lyric file)))
+ (setq file (funcall emms-lyrics-find-lyric-function file)))
+ (when (and file (not (string= file "")) (file-exists-p file))
+ (with-temp-buffer
+ (let ((coding-system-for-read emms-lyrics-coding-system))
+ (insert-file-contents file)
+ (while (search-forward-regexp "\\[[0-9:.]+\\].*" nil t)
+ (let ((lyric-string (match-string 0))
+ (time 0)
+ (lyric ""))
+ (setq lyric
+ (emms-replace-regexp-in-string ".*\\]" "" lyric-string))
+ (while (string-match "\\[[0-9:.]+\\]" lyric-string)
+ (let* ((time-string (match-string 0 lyric-string))
+ (semi-pos (string-match ":" time-string)))
+ (setq time
+ (+ (* (string-to-number
+ (substring time-string 1 semi-pos))
+ 60)
+ (string-to-number
+ (substring time-string
+ (1+ semi-pos)
+ (1- (length time-string))))))
+ (setq lyric-string
+ (substring lyric-string (length time-string)))
+ (setq emms-lyrics-alist
+ (append emms-lyrics-alist `((,time ,lyric))))
+ (setq time 0))))))
+ t)))
(defun emms-lyrics-start ()
"Start displaying lryics."
@@ -169,7 +171,7 @@ FILE should be under the same directory as the music file, or under
'name)))
(emms-lyrics-read-file
(emms-replace-regexp-in-string
- (file-name-extension file) "lrc" file)))
+ (concat "\\." (file-name-extension file) "\\'") ".lrc" file)))
(emms-lyrics-set-timer)))
(defun emms-lyrics-stop ()
@@ -332,7 +334,8 @@ display."
(format emms-lyrics-display-format lyric))
(force-mode-line-update))
(when emms-lyrics-display-on-minibuffer
- (message lyric))))
+ (unless (minibuffer-window-active-p (selected-window))
+ (message lyric)))))
(defun emms-lyrics-find-lyric (file)
"Use `emms-source-file-gnu-find' to find lrc FILE. You should specify
diff --git a/emms-volume-amixer.el b/emms-volume-amixer.el
index 7a35435..379dfdb 100644
--- a/emms-volume-amixer.el
+++ b/emms-volume-amixer.el
@@ -49,17 +49,38 @@
(defun emms-volume-amixer-sset-master (var)
"Change amixer master volume by VAR."
- (start-process "mixer" nil "amixer" "sset" emms-volume-amixer-control var))
-
-(defun emms-volume-amixer-raise ()
- "Increase volume by 2%."
- (interactive)
- (emms-volume-amixer-sset-master "2%+"))
+ (message "Playback channels: %s"
+ (with-temp-buffer
+ (when (zerop
+ (call-process "amixer" nil (current-buffer) nil
+ "sset" emms-volume-amixer-control
+ (format "%d%%%s" (abs var)
+ (if (< var 0) "-" "+"))))
+ (if (re-search-backward "\\[\\([0-9]+%\\)\\]" nil t)
+ (match-string 1))))))
+
+(defvar emms-volume-amixer-raise-commands
+ '(?p ?k up ?+ ?=))
+(defvar emms-volume-amixer-lower-commands
+ '(?n ?j down ?-))
+
+(defun emms-volume-amixer-raise (&optional arg)
+ (interactive "P")
+ (if arg
+ (emms-volume-amixer-sset-master -2)
+ (emms-volume-amixer-sset-master 2))
+ (let (command)
+ (while (progn
+ (setq command (read-event))
+ (cond ((member command emms-volume-amixer-raise-commands)
+ (emms-volume-amixer-sset-master 2))
+ ((member command emms-volume-amixer-lower-commands)
+ (emms-volume-amixer-sset-master -2)))))
+ (setq unread-command-events (list command))))
(defun emms-volume-amixer-lower ()
- "Decrease volume by 2%."
(interactive)
- (emms-volume-amixer-sset-master "2%-"))
+ (emms-volume-amixer-raise -1))
(provide 'emms-volume-amixer)