From 25fa26fda5a01baafcbd3beac112b4a65313aeab Mon Sep 17 00:00:00 2001 From: Simon Parri Date: Fri, 25 Jul 2025 00:11:53 +0200 Subject: Emacs, VimFX: Switch from Bongo to empv --- common/.emacs.d/init.el | 120 ++++++++++++++++++++++++++---------------------- common/.vimfx/config.js | 2 +- 2 files changed, 65 insertions(+), 57 deletions(-) (limited to 'common') diff --git a/common/.emacs.d/init.el b/common/.emacs.d/init.el index 45867f7..aeaf99f 100644 --- a/common/.emacs.d/init.el +++ b/common/.emacs.d/init.el @@ -2065,8 +2065,6 @@ Only works on a single file." (keymap-modify dired-mode-map "C-c &" 'dired-do-async-command-silent - "C-c l" 'bongo-dired-library-mode - "C-c m" 'bongo-dired-play-line "TAB" 'dired-subtree-cycle) (defvar dired-id3--hist () @@ -2985,54 +2983,64 @@ instead." (pulseaudio-change-sink (- (or amt pulseaudio-default-amt))))) -(use-package bongo +(use-package empv + :if (group-enabled-p 'music) :ensure t - :commands (bongo-dired-library-mode - bongo-dired-play-line - bongo-pause/resume - bongo-stop - bongo-next - bongo-previous) :config - (require 'xdg) + (require 'dired) (setq - bongo-mpv-extra-arguments () - bongo-default-directory - (concat (or (xdg-user-dir "MUSIC") - (expand-file-name "~/mus")) - "/") - bongo-field-separator " — " - bongo-display-track-icons nil - bongo-insert-album-covers t - bongo-mark-played-tracks t - bongo-prefer-library-buffers nil - bongo-custom-backend-matchers - '((mpv . ((local-file "file:" "http:" "https:" "ftp:") "opus" "m4a")) - (mpv . ("https:" . t)))) - - (defun my/bongo-switch-buffers (&optional prompt) - (interactive "P") - (let ((dir (if prompt - (read-directory-name - "Library directory: " - bongo-default-directory) - bongo-default-directory))) - (with-current-buffer (dired-noselect dir) - (bongo-dired-library-mode) - (display-buffer (current-buffer))))) - - (keymap-modify bongo-playlist-mode-map - " " 'my/bongo-switch-buffers) - - :config/el-patch - (defun bongo-compose-remote-option (socket-file) - "Get the command line argument for starting mpv's remote interface at SOCKET-FILE." - (when (equal bongo-mpv-remote-option 'unknown) - (setq bongo-mpv-remote-option (bongo--mpv-get-remote-option))) - (el-patch-swap - (list bongo-mpv-remote-option socket-file) - (list (format "%s=%s" bongo-mpv-remote-option socket-file))))) + empv-playlist-dir (xdg-user-dir "MUSIC") + empv-base-directory empv-playlist-dir + empv-use-consult-if-possible nil + empv-invidious-instance "https://yewtu.be/api/v1") + + (keymap-set dired-mode-map "e" 'empv-play-media-at-point) + + (defvar empv-mode-line-format + (concat " " (propertize "%t" 'face 'bold) " " (propertize "[%p]" 'face 'italic))) + + (defvar empv-mode-line-string) + + (defvar empv-mode-line-timer) + + (defun empv-mode-line-update () + (empv--let-properties + '(time-pos + duration + metadata + path) + (if .path + (let ((progress + (when (and .time-pos .duration) + (thread-last + (/ .time-pos .duration) + (* 100) + (format "%d%%")))) + (path .path)) + (let-alist .metadata + (setq empv-mode-line-string + (format-spec empv-mode-line-format + `((?t . ,(or (and .TITLE + (string-limit .TITLE 50)) + (string-limit path 50 t))) + (?a . ,(or .ARTIST "")) + (?A . ,(or .ALBUM "")) + (?G . ,(or .GENRE "")) + (?p . ,(or progress "")))))) + (force-mode-line-update)) + (setq empv-mode-line-string "")))) + + (define-minor-mode empv-mode-line-mode + "" + :global t + (if empv-mode-line-mode + (progn + (add-to-list 'global-mode-string 'empv-mode-line-string t) + (setq empv-mode-line-timer + (run-at-time t 2 #'empv-mode-line-update))) + (delq 'empv-mode-line-string global-mode-string) + (cancel-timer empv-mode-line-timer)))) (use-package yeetube :config @@ -3919,7 +3927,7 @@ instead." (define-rrr networks "nmtui" "nmtui") (define-rrr bluetooth "bluetuith" "bluetuith") (define-rrr mixer "pulsemixer" "pulsemixer") - (define-rrr music "bongo" "^\\*Bongo.*\\*$") + (defalias 'music 'empv-playlist-select) (define-rrr wallpapers "dired-wallpapers" "\\*wallpapers\\*") (defalias 'walls 'wallpapers) @@ -4160,14 +4168,14 @@ instead." ("s-/" pulseaudio-mute) ("" pulseaudio-mute) - ("s-'" bongo-pause/resume) - ("" bongo-pause/resume) - ("s-\"" bongo-stop) - ("" bongo-stop) - ("s->" bongo-next) - ("" bongo-next) - ("s-<" bongo-previous) - ("" bongo-previous) + ("s-'" empv-toggle) + ("" empv-toggle) + ("s-\"" empv-exit) + ("" empv-exit) + ("s->" empv-playlist-next) + ("" empv-playlist-nex) + ("s-<" empv-playlist-previous) + ("" empv-playlist-previous) ("s-a" lower-transparency) ("s-A" raise-transparency) @@ -4181,7 +4189,7 @@ instead." ("s-x e" email) ("s-x c" jabber-global-keymap) ("s-x t" torrents) - ;; ("s-x v" empv-toggle-video) + ("s-x v" empv-toggle-video) ("s-x w" networks) ("s-x W" bluetooth) ("s-x m" mixer) diff --git a/common/.vimfx/config.js b/common/.vimfx/config.js index b384a21..cb9417d 100644 --- a/common/.vimfx/config.js +++ b/common/.vimfx/config.js @@ -125,7 +125,7 @@ const sendFn = msg => let commands = { emacsclient: rcurry(execOnLink, "emacsclient", "%u"), - emacsclient_media: rcurry(execOnLink, "emacsclient", "--eval", "(bongo-play-file \"%u\")"), + emacsclient_media: rcurry(execOnLink, "emacsclient", "--eval", "(empv-play \"%u\")"), emacsclient_eww: rcurry(execOnLink, "emacsclient", "--eval", "(eww \"%u\")"), toggle_images: toggleImages, reload_userchrome: ({vim}) => reloadUserChrome(a => vim.notify(a)), -- cgit v1.2.3