Headphone mechanism change

This commit is contained in:
2026-08-20 10:18:57 +03:00
parent 4ea2421734
commit 8be92183bb
4 changed files with 76 additions and 12 deletions
+18 -3
View File
@@ -43,9 +43,24 @@
** Headphones
#+begin_src emacs-lisp
(defun azos/connect-headphones ()
(interactive)
(start-process-shell-command "connect-headphones" nil "azos-connect-headphones-whmx4000"))
(defun azos/connect-headphones (&optional arg)
"Connect to headphones via bluetoothctl.
Without prefix ARG, connects to the first device in the list.
With prefix ARG, prompts to choose from all configured devices."
(interactive "P")
(if (not arg)
(start-process-shell-command "connect-headphones" nil "azos-connect-headphones")
(let* ((raw (shell-command-to-string "azos-connect-headphones --list"))
(lines (split-string (string-trim raw) "\n" t))
(choices (mapcar (lambda (line)
(let ((space (string-match " " line)))
(cons (substring line (1+ space))
(substring line 0 space))))
lines))
(name (completing-read "Connect headphones: " (mapcar #'car choices) nil t))
(mac (cdr (assoc name choices))))
(start-process-shell-command "connect-headphones" nil
(concat "azos-connect-headphones --mac " mac)))))
(define-key azos/global-minor-mode/open-keymap
(kbd "h") 'azos/connect-headphones)