Headphone mechanism change
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user