Prefer start-process to shell-command for pulse-audio module
Continuing the series of easy-win commits that increase the speed of commands that I was previously using `shell-command` to run by using `start-process` instead.
This commit is contained in:
parent
7ec4dca723
commit
15d889fa0e
1 changed files with 49 additions and 13 deletions
|
@ -6,10 +6,19 @@
|
|||
|
||||
;;; Code:
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Dependencies
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(require 'string)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Constants
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defconst pulse-audio/step-size 5
|
||||
"The size by which to increase or decrease the volume.")
|
||||
|
||||
(defconst pulse-audio/install-kbds? t
|
||||
"When t, install keybindings defined herein.")
|
||||
|
||||
|
@ -17,38 +26,65 @@
|
|||
;; Library
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defun pulse-audio/message (x)
|
||||
"Output X to *Messages*."
|
||||
(message (string/format "[pulse-audio.el] %s" x)))
|
||||
|
||||
(defun pulse-audio/toggle-mute ()
|
||||
"Mute the default sink."
|
||||
(interactive)
|
||||
(shell-command "pactl set-sink-mute @DEFAULT_SINK@ toggle")
|
||||
(message (string/format "[pulse-audio.el] Mute toggled.")))
|
||||
(start-process
|
||||
"*pactl<pulse-audio/toggle-mute>*"
|
||||
nil
|
||||
"pactl"
|
||||
"set-sink-mute"
|
||||
"@DEFAULT_SINK@"
|
||||
"toggle")
|
||||
(pulse-audio/message "Mute toggled."))
|
||||
|
||||
(defun pulse-audio/toggle-microphone ()
|
||||
"Mute the default sink."
|
||||
(interactive)
|
||||
(shell-command "pactl set-source-mute @DEFAULT_SOURCE@ toggle")
|
||||
(message (string/format "[pulse-audio.el] Microphone toggled.")))
|
||||
(start-process
|
||||
"*pactl<pulse-audio/toggle-mute>*"
|
||||
nil
|
||||
"pactl"
|
||||
"set-source-mute"
|
||||
"@DEFAULT_SOURCE@"
|
||||
"toggle")
|
||||
(pulse-audio/message "Microphone toggled."))
|
||||
|
||||
(defun pulse-audio/lower-volume ()
|
||||
(defun pulse-audio/decrease-volume ()
|
||||
"Low the volume output of the default sink."
|
||||
(interactive)
|
||||
(shell-command "pactl set-sink-volume @DEFAULT_SINK@ -10%")
|
||||
(message (string/format "[pulse-audio.el] Volume lowered.")))
|
||||
(start-process
|
||||
"*pactl<pulse-audio/toggle-mute>*"
|
||||
nil
|
||||
"pactl"
|
||||
"set-sink-volume"
|
||||
"@DEFAULT_SINK@"
|
||||
(string/format "-%s%%" pulse-audio/step-size))
|
||||
(pulse-audio/message "Volume decreased."))
|
||||
|
||||
(defun pulse-audio/raise-volume ()
|
||||
(defun pulse-audio/increase-volume ()
|
||||
"Raise the volume output of the default sink."
|
||||
(interactive)
|
||||
(shell-command "pactl set-sink-volume @DEFAULT_SINK@ +10%")
|
||||
(message (string/format "[pulse-audio.el] Volume raised.")))
|
||||
|
||||
(start-process
|
||||
"*pactl<pulse-audio/toggle-mute>*"
|
||||
nil
|
||||
"pactl"
|
||||
"set-sink-volume"
|
||||
"@DEFAULT_SINK@"
|
||||
(string/format "+%s%%" pulse-audio/step-size))
|
||||
(pulse-audio/message "Volume increased."))
|
||||
|
||||
(when pulse-audio/install-kbds?
|
||||
(exwm-input-set-key
|
||||
(kbd "<XF86AudioMute>") #'pulse-audio/toggle-mute)
|
||||
(exwm-input-set-key
|
||||
(kbd "<XF86AudioLowerVolume>") #'pulse-audio/lower-volume)
|
||||
(kbd "<XF86AudioLowerVolume>") #'pulse-audio/decrease-volume)
|
||||
(exwm-input-set-key
|
||||
(kbd "<XF86AudioRaiseVolume>") #'pulse-audio/raise-volume)
|
||||
(kbd "<XF86AudioRaiseVolume>") #'pulse-audio/increase-volume)
|
||||
(exwm-input-set-key
|
||||
(kbd "<XF86AudioMicMute>") #'pulse-audio/toggle-microphone))
|
||||
|
||||
|
|
Loading…
Reference in a new issue