summaryrefslogtreecommitdiffhomepage
path: root/lib/media
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-06-13 01:19:58 +0100
committerjao <jao@gnu.org>2021-06-13 01:20:25 +0100
commit9a09bf70f2a363c43cd381a2b8968ddfde22e43b (patch)
treecb9e8c339d94f640490ecdc3f97330dc92ea0946 /lib/media
parentee1f7669953d1af534f282b2ef5ec147ecc090b3 (diff)
downloadelibs-9a09bf70f2a363c43cd381a2b8968ddfde22e43b.tar.gz
elibs-9a09bf70f2a363c43cd381a2b8968ddfde22e43b.tar.bz2
a quick and dirty, yet sweet, mpd album selector with completion
Diffstat (limited to 'lib/media')
-rw-r--r--lib/media/jao-mpc.el14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/media/jao-mpc.el b/lib/media/jao-mpc.el
index 6f74243..2ad27a4 100644
--- a/lib/media/jao-mpc.el
+++ b/lib/media/jao-mpc.el
@@ -251,5 +251,19 @@
(when secondary-port (jao-mpc-connect secondary-port))
(jao-minibuffer-add-msg-variable 'jao-mpc-minibuffer-str 1))
+(defvar jao-mpc--album-titles nil)
+(defconst jao-mpc--albums-cmd
+ "-f '%album% - %artist%' find \"(ALBUM =~ '.*')\" | uniq")
+
+;;;###autoload
+(defun jao-mpc-select-album ()
+ (interactive)
+ (let ((albums (or jao-mpc--album-titles
+ (setq jao-mpc--album-titles
+ (split-string (jao-mpc--cmd jao-mpc--albums-cmd)
+ "\n" t)))))
+ (when-let (album (completing-read "Play album: " albums nil t))
+ (jao-mpc--add-and-play (car (split-string album "-" t " "))))))
+
(provide 'jao-mpc)
;;; jao-mpc.el ends here