diff options
-rw-r--r-- | exwm.org | 5 | ||||
-rw-r--r-- | init.org | 117 | ||||
-rw-r--r-- | lib/media/jao-mpris.el | 39 |
3 files changed, 84 insertions, 77 deletions
@@ -253,6 +253,9 @@ (jao-def-exwm-runner jao-exwm-vlc 4 "VLC" "vlc") + (jao-def-exwm-runner jao-exwm-deezer 5 "Deezer" "deezer-desktop") + (defalias 'jao-spotify-list #'jao-exwm-deezer) + (jao-def-exwm-runner jao-exwm-slack 0 "Slack" "slack") (jao-def-exwm-runner jao-exwm-signal 0 "Signal" "signal-desktop") @@ -516,7 +519,7 @@ ([?\s-P] . jao-transpose-windows-prev) ([?\s-p] . jao-prev-window) ([?\s-r] . app-launcher-run-app) - ([?\s-s] . jao-transient-spotify) + ([?\s-s] . jao-transient-streaming) ([?\s-t] . vterm) ([?\s-w] . jao-transient-utils) ([?\s-z] . jao-transient-sleep) @@ -2901,6 +2901,30 @@ (global-set-key (kbd "<f4>") #'jao-toggle-audio-applet) #+end_src +*** mpris + #+begin_src emacs-lisp + (use-package jao-mpris + :demand t + :config + (defun jao-mpris-setup-aliases () + (setq espotify-play-uri-function #'espotify-play-uri-with-dbus) + (defalias 'jao-streaming-list #'jao-term-ncmpcpp) + (defalias 'jao-streaming-lyrics 'jao-show-lyrics) + (defalias 'jao-streaming-toggle #'jao-mpris-play-pause) + (defalias 'jao-streaming-next #'jao-mpris-next) + (defalias 'jao-streaming-prev #'jao-mpris-previous) + (defalias 'jao-streaming-current #'jao-mpris-show-osd) + (defalias 'jao-streaming-seek #'jao-mpris-seek) + (defalias 'jao-streaming-seek-back #'jao-mpris-seek-back) + (defalias 'jao-streaming-volume #'jao-mpris-vol) + (defalias 'jao-streaming-volume-down #'jao-mpris-vol-down))) + + (jao-mpris-setup-aliases) + (jao-mpris-register "mopidy" :system (if jao-modeline-in-minibuffer-p -10 70)) + (jao-mpris-register "chromium" :session) + (jao-mpris-register "firefox" :session) + + #+end_src *** spotify Access to spotify uses packages tangled from [[./lib/media/espotify.org][espotify.org]], which offers functionality tailored to the completion engines at hand: @@ -2911,55 +2935,36 @@ :demand t :init (setq espotify-service-name "mopidy")) (use-package consult-spotify :demand t) - (defalias 'jao-spotify-album #'consult-spotify-album) - (defalias 'jao-spotify-track #'consult-spotify-track) - (defalias 'jao-spotify-artist #'consult-spotify-artist) - (defalias 'jao-spotify-playlist #'consult-spotify-playlist) + (defalias 'jao-streaming-album #'consult-spotify-album) + (defalias 'jao-streaming-track #'consult-spotify-track) + (defalias 'jao-streaming-artist #'consult-spotify-artist) + (defalias 'jao-streaming-playlist #'consult-spotify-playlist) (jao-def-exec-in-term "ncmpcpp" "ncmpcpp" (jao-afio--goto-scratch)) - (use-package jao-mpris - :demand t - :config - (defun jao-mpris-setup-aliases () - (setq espotify-play-uri-function #'espotify-play-uri-with-dbus) - (defalias 'jao-spotify-list #'jao-term-ncmpcpp) - (defalias 'jao-spotify-lyrics 'jao-show-lyrics) - (defalias 'jao-spotify-toggle #'jao-mpris-play-pause) - (defalias 'jao-spotify-next #'jao-mpris-next) - (defalias 'jao-spotify-prev #'jao-mpris-previous) - (defalias 'jao-spotify-current #'jao-mpris-show-osd) - (defalias 'jao-spotify-seek #'jao-mpris-seek) - (defalias 'jao-spotify-seek-back #'jao-mpris-seek-back) - (defalias 'jao-spotify-volume #'jao-mpris-vol) - (defalias 'jao-spotify-volume-down #'jao-mpris-vol-down))) - - (jao-mpris-setup-aliases) - (jao-mpris-register "mopidy" :system (if jao-modeline-in-minibuffer-p -10 70)) - (use-package jao-spt :demand t :config (defun jao-spt-setup-aliases () (setq espotify-play-uri-function #'jao-spt-play-uri) - (defalias 'jao-spotify-list #'jao-term-spt) - (defalias 'jao-spotify-lyrics #'jao-spt-show-lyrics) - (defalias 'jao-spotify-toggle #'jao-spt-toggle) - (defalias 'jao-spotify-next #'jao-spt-next) - (defalias 'jao-spotify-prev #'jao-spt-previous) - (defalias 'jao-spotify-current #'jao-spt-echo-current) - (defalias 'jao-spotify-seek #'jao-spt-seek) - (defalias 'jao-spotify-seek-back #'jao-spt-seek-back) - (defalias 'jao-spotify-volume #'jao-spt-vol) - (defalias 'jao-spotify-volume-down #'jao-spt-vol-down))) - - (defvar jao-spt-on t) + (defalias 'jao-streaming-list #'jao-term-spt) + (defalias 'jao-streaming-lyrics #'jao-spt-show-lyrics) + (defalias 'jao-streaming-toggle #'jao-spt-toggle) + (defalias 'jao-streaming-next #'jao-spt-next) + (defalias 'jao-streaming-prev #'jao-spt-previous) + (defalias 'jao-streaming-current #'jao-spt-echo-current) + (defalias 'jao-streaming-seek #'jao-spt-seek) + (defalias 'jao-streaming-seek-back #'jao-spt-seek-back) + (defalias 'jao-streaming-volume #'jao-spt-vol) + (defalias 'jao-streaming-volume-down #'jao-spt-vol-down))) + + (defvar jao-spt-on nil) (defun jao-spt-on-p () jao-spt-on) - (jao-spt-setup-aliases) + ;; (jao-spt-setup-aliases) (jao-def-exec-in-term "spt" "spt" (jao-afio--goto-scratch-1)) - (defun jao-spotify-toggle-player () + (defun jao-streaming-toggle-player () (interactive) (if jao-spt-on (jao-mpris-setup-aliases) (jao-spt-setup-aliases)) (message "%s activated " @@ -3024,13 +3029,13 @@ (defun jao-player-seek-10 () (interactive) (jao-player-seek 10)) (defun jao-player-seek--10 () (interactive) (jao-player-seek -10)) - (defun jao-spotify-clear () (interactive) (jao-mpc-clear jao-mopidy-port)) + (defun jao-streaming-clear () (interactive) (jao-mpc-clear jao-mopidy-port)) - (defun jao-spotify-echo-current () + (defun jao-streaming-echo-current () (interactive) (jao-mpc-echo-current jao-mopidy-port)) - (defun jao-spotify-show-playlist () + (defun jao-streaming-show-playlist () (interactive) (jao-mpc-show-playlist jao-mopidy-port)) @@ -3041,28 +3046,28 @@ (jao-def-exec-in-term "aptitude" "aptitude" (jao-afio--goto-scratch)) (jao-def-exec-in-term "htop" "htop" (jao-afio--goto-scratch)) - (transient-define-prefix jao-transient-spotify () + (transient-define-prefix jao-transient-streaming () [:description (lambda () (format "Spotify using %s" (if jao-spt-on "spt" "MPRIS"))) ["Search" - ("a" "album" jao-spotify-album) - ("A" "artist" jao-spotify-artist) - ("t" "track" jao-spotify-track) - ("P" "playlist" jao-spotify-playlist)] + ("a" "album" jao-streaming-album) + ("A" "artist" jao-streaming-artist) + ("t" "track" jao-streaming-track) + ("P" "playlist" jao-streaming-playlist)] ["Play" - ("s" "toggle" jao-spotify-toggle) - ("n" "next" jao-spotify-next) - ("p" "previous" jao-spotify-prev)] + ("s" "toggle" jao-streaming-toggle) + ("n" "next" jao-streaming-next) + ("p" "previous" jao-streaming-prev)] ["Seek & shout" - ("f" "seek fwd" jao-spotify-seek :transient t) - ("F" "seek bwd" jao-spotify-seek-back :transient t) - ("u" "up" jao-spotify-volume :transient t) - ("d" "down" jao-spotify-volume-down :transient t)] + ("f" "seek fwd" jao-streaming-seek :transient t) + ("F" "seek bwd" jao-streaming-seek-back :transient t) + ("u" "up" jao-streaming-volume :transient t) + ("d" "down" jao-streaming-volume-down :transient t)] ["Browse" - ("l" "playing list" jao-spotify-list) - ("L" "lyrics" jao-spotify-lyrics) - ("w" "currently playing" jao-spotify-current) - ("T" "toggle player" jao-spotify-toggle-player)] + ("l" "playing list" jao-streaming-list) + ("L" "lyrics" jao-streaming-lyrics) + ("w" "currently playing" jao-streaming-current) + ("T" "toggle player" jao-streaming-toggle-player)] ["Act" :if jao-spt-on-p ("k" "like" jao-spt-like) ("K" "dislike" jao-spt-dislike) diff --git a/lib/media/jao-mpris.el b/lib/media/jao-mpris.el index d34480a..c9f917a 100644 --- a/lib/media/jao-mpris.el +++ b/lib/media/jao-mpris.el @@ -90,6 +90,9 @@ (defun jao-mpris--get (k &optional l) (alist-get k (or l jao-mpris--current))) +(defun jao-mpris--set-current (k v) + (setf (alist-get k jao-mpris--current "" t) v)) + (defun jao-mpris--fmt-time (x suffix) (if x (format "%02d:%02d%s" (/ x 60) (mod x 60) (or suffix "")) "")) @@ -138,26 +141,22 @@ (jao-minibuffer-add-variable 'jao-mpris-track-string order))) (defun jao-mpris--handler (_iname properties &rest _args) - (when properties - (let ((st (caadr (assoc "PlaybackStatus" properties))) - (md (caadr (assoc "Metadata" properties)))) - (cond ((and st (not (string= "Playing" st))) - (setq jao-mpris-track-string "") - (setq jao-mpris--current - (cons (cons 'status st) - (assq-delete-all 'status jao-mpris--current))) - (jao-minibuffer-refresh) - (message "Music %s" st)) - (md (let ((tno (caadr (assoc "xesam:trackNumber" md))) - (tlt (caadr (assoc "xesam:title" md))) - (art (caaadr (assoc "xesam:artist" md))) - (alb (caadr (assoc "xesam:album" md))) - (len (caadr (assoc "mpris:length" md)))) - (setq jao-mpris--current - `((track . ,tno) (title . ,tlt) - (artist . ,art) (album . ,alb) - (length . ,len) (status . ,st))) - (jao-mpris--track jao-mpris--current))))))) + (let ((inhibit-message t)) + (message "Receivied properties: %S from %s" properties _iname)) + (when-let (md (caadr (assoc "Metadata" properties))) + (let ((tno (caadr (assoc "xesam:trackNumber" md))) + (tlt (caadr (assoc "xesam:title" md))) + (art (caaadr (assoc "xesam:artist" md))) + (alb (caadr (assoc "xesam:album" md))) + (len (caadr (assoc "mpris:length" md)))) + (jao-mpris--set-current 'track tno) + (jao-mpris--set-current 'title tlt) + (jao-mpris--set-current 'artist art) + (jao-mpris--set-current 'album alb) + (jao-mpris--set-current 'length len))) + (when-let (st (caadr (assoc "PlaybackStatus" properties))) + (jao-mpris--set-current 'status st)) + (jao-mpris--track jao-mpris--current)) ;;;###autoload (defun jao-mpris-register (name &optional bus order) |