From a32821d78893d654523b8f6f421408e756b7723b Mon Sep 17 00:00:00 2001 From: jao Date: Sun, 22 May 2022 00:52:48 +0100 Subject: mopidy-tidal --- init.org | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'init.org') diff --git a/init.org b/init.org index c0dc2bb..282030d 100644 --- a/init.org +++ b/init.org @@ -3179,17 +3179,27 @@ :demand t :commands jao-mpc-setup) - ;; (defvar jao-mopidy-port 6669) - (defvar jao-mopidy-port nil) + (defvar jao-mopidy-port 6669) + (defvar jao-mpc-last-port nil) + + (defun jao-mpc-toggle-port () + (interactive) + (setq jao-mpc-last-port (unless jao-mpc-last-port jao-mopidy-port) + jao-mpc-port jao-mpc-last-port)) + (jao-mpc-setup jao-mopidy-port (if jao-modeline-in-minibuffer -10 70)) - (defun jao-mpc-pport () - (when (jao-mpc--playing-p jao-mopidy-port) jao-mopidy-port)) + (defun jao-mpc-pport (&optional mop) + (cond ((or mop (jao-mpc--playing-p jao-mopidy-port)) jao-mopidy-port) + ((jao-mpc--playing-p) nil) + (t jao-mpc-last-port))) (defmacro jao-defun-play (name &optional mpc-name) - `(defun ,(intern (format "jao-player-%s" name)) () - (interactive) - (,(intern (format "jao-mpc-%s" (or mpc-name name))) (jao-mpc-pport)))) + (let ((arg (gensym))) + `(defun ,(intern (format "jao-player-%s" name)) (&optional ,arg) + (interactive "P") + (,(intern (format "jao-mpc-%s" (or mpc-name name))) + (setq jao-mpc-last-port (jao-mpc-pport ,arg)))))) (jao-defun-play toggle) (jao-defun-play next) @@ -3198,10 +3208,11 @@ (jao-defun-play echo echo-current) (jao-defun-play list show-playlist) (jao-defun-play info lyrics-track-data) + (jao-defun-play browse show-albums) + (jao-defun-play select-album) (defun jao-player-seek (delta) (jao-mpc-seek delta (jao-mpc-pport))) - (defalias 'jao-player-browse 'jao-mpc-show-albums) (defalias 'jao-player-connect 'jao-mpc-connect) (defalias 'jao-player-play 'jao-mpc-play) #+end_src @@ -3278,12 +3289,11 @@ ("m" "toggle" jao-player-toggle) ("n" "next" jao-player-next) ("p" "previous" jao-player-previous) - ("s" "toggle streaming" jao-streaming-toggle) - ] + ("s" "select album" jao-player-select-album)] ["Seek and search" ("f" "seek fwd" jao-player-seek-10 :transient t) ("F" "seek bwd" jao-player-seek--10 :transient t) - ("a" "select album" jao-mpc-select-album)] + ("a" "search album" jao-mpc-search-and-select-album)] ["Browse" ("b" "browse" jao-player-browse) ("l" "show play list" jao-player-list) @@ -3303,7 +3313,12 @@ ("N" "next random album" jao-random-album-next) ("r" (lambda () (concat (if jao-random-album-p "dis" "en") "able random album")) - jao-random-album-toggle)]]) + jao-random-album-toggle) + ("P" (lambda () + (concat "Toggle to " + (if (equal jao-mpc-last-port jao-mopidy-port) + "mpd" "mopidy"))) + jao-mpc-toggle-port)]]) (global-set-key (kbd "s-m") #'jao-transient-media) -- cgit v1.2.3