Load after exwm inits

This commit is contained in:
Benson Chu 2020-09-26 18:43:46 -05:00
parent ad23b71eb1
commit 69ab4d5e62

View file

@ -768,26 +768,28 @@
(defvar laptop-sink-index 0)
(defvar hdmi-pcie-interface nil)
(let* ((result (shell-command-to-string "pactl list short sinks")))
(when (string-match "\\([0-9]\\).*analog-stereo" result)
(setq laptop-sink-index
(string-to-number
(match-string 1 result))))
(when (string-match "[0-9].*\\(pci-.*\\)\\.hdmi-stereo" result)
(setq hdmi-pcie-interface
(match-string 1 result))))
(defun setup-headphone-stuff ()
(interactive)
(let* ((result (shell-command-to-string "pactl list short sinks")))
(when (string-match "\\([0-9]\\).*analog-stereo" result)
(setq laptop-sink-index
(string-to-number
(match-string 1 result))))
(when (string-match "[0-9].*\\(pci-.*\\)\\.hdmi-stereo" result)
(setq hdmi-pcie-interface
(match-string 1 result))))
(when hdmi-pcie-interface
(let* ((result (shell-command-to-string "pacmd list-modules"))
(split (cdr (split-string result "index: "))))
(loop for mod in split
while (not
(string-match (format "\\([0-9]+\\)\n.*\n.*name=\"%s\"" hdmi-pcie-interface)
mod))
finally
do (shell-command
(format "pactl unload-module %s"
(match-string 1 mod))))))
(when hdmi-pcie-interface
(let* ((result (shell-command-to-string "pacmd list-modules"))
(split (cdr (split-string result "index: "))))
(loop for mod in split
while (not
(string-match (format "\\([0-9]+\\)\n.*\n.*name=\"%s\"" hdmi-pcie-interface)
mod))
finally
do (shell-command
(format "pactl unload-module %s"
(match-string 1 mod)))))))
(defun current-speakers ()
(let ((string (shell-command-to-string "pactl list sinks | grep 'Active Port: '")))
@ -806,4 +808,8 @@
(message (format "Switched to: %s" (current-speakers))))
(exwm-global-set-key (kbd "s-s") #'toggle-audio-output)
(use-package exwm
:config
(add-hook 'exwm-init-hook #'setup-headphone-stuff))
#+end_src