From 9a09bf70f2a363c43cd381a2b8968ddfde22e43b Mon Sep 17 00:00:00 2001 From: jao Date: Sun, 13 Jun 2021 01:19:58 +0100 Subject: a quick and dirty, yet sweet, mpd album selector with completion --- lib/media/jao-mpc.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib/media') 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 -- cgit v1.2.3