2019-10-09 13:13:56 +02:00
|
|
|
;;; pulse-audio.el --- Control audio with Elisp -*- lexical-binding: t -*-
|
2020-08-31 15:53:34 +02:00
|
|
|
|
2019-10-09 13:13:56 +02:00
|
|
|
;; Author: William Carroll <wpcarro@gmail.com>
|
2020-08-31 15:53:34 +02:00
|
|
|
;; Version: 0.0.1
|
|
|
|
;; Package-Requires: ((emacs "24"))
|
|
|
|
;; Homepage: https://user.git.corp.google.com/wpcarro/briefcase
|
2019-10-09 13:13:56 +02:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
;; Because everything in my configuration is turning into Elisp these days.
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
2019-12-23 13:19:59 +01:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Dependencies
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2019-12-23 18:31:42 +01:00
|
|
|
(require 'prelude)
|
2019-12-23 13:19:59 +01:00
|
|
|
(require 'string)
|
|
|
|
|
2019-10-09 13:13:56 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Constants
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2020-08-31 15:53:34 +02:00
|
|
|
(defconst pulse-audio--step-size 5
|
2019-12-23 13:19:59 +01:00
|
|
|
"The size by which to increase or decrease the volume.")
|
|
|
|
|
2019-10-09 13:13:56 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; Library
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2020-08-31 15:53:34 +02:00
|
|
|
(defun pulse-audio--message (x)
|
2019-12-23 13:19:59 +01:00
|
|
|
"Output X to *Messages*."
|
2020-09-01 00:28:47 +02:00
|
|
|
(message (string-format "[pulse-audio.el] %s" x)))
|
2019-12-23 13:19:59 +01:00
|
|
|
|
2020-08-31 15:53:34 +02:00
|
|
|
(defun pulse-audio-toggle-mute ()
|
2019-10-09 13:13:56 +02:00
|
|
|
"Mute the default sink."
|
|
|
|
(interactive)
|
2020-08-31 18:05:31 +02:00
|
|
|
(prelude-start-process
|
2020-08-31 15:53:34 +02:00
|
|
|
:name "pulse-audio-toggle-mute"
|
2019-12-23 18:31:42 +01:00
|
|
|
:command "pactl set-sink-mute @DEFAULT_SINK@ toggle")
|
2020-08-31 15:53:34 +02:00
|
|
|
(pulse-audio--message "Mute toggled."))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
2020-08-31 15:53:34 +02:00
|
|
|
(defun pulse-audio-toggle-microphone ()
|
2019-12-23 11:56:38 +01:00
|
|
|
"Mute the default sink."
|
|
|
|
(interactive)
|
2020-08-31 18:05:31 +02:00
|
|
|
(prelude-start-process
|
2020-08-31 15:53:34 +02:00
|
|
|
:name "pulse-audio-toggle-microphone"
|
2019-12-23 18:31:42 +01:00
|
|
|
:command "pactl set-source-mute @DEFAULT_SOURCE@ toggle")
|
2020-08-31 15:53:34 +02:00
|
|
|
(pulse-audio--message "Microphone toggled."))
|
2019-12-23 11:56:38 +01:00
|
|
|
|
2020-08-31 15:53:34 +02:00
|
|
|
(defun pulse-audio-decrease-volume ()
|
2019-10-09 13:13:56 +02:00
|
|
|
"Low the volume output of the default sink."
|
|
|
|
(interactive)
|
2020-08-31 18:05:31 +02:00
|
|
|
(prelude-start-process
|
2020-08-31 15:53:34 +02:00
|
|
|
:name "pulse-audio-decrease-volume"
|
2020-09-01 00:28:47 +02:00
|
|
|
:command (string-format "pactl set-sink-volume @DEFAULT_SINK@ -%s%%"
|
2020-08-31 15:53:34 +02:00
|
|
|
pulse-audio--step-size))
|
|
|
|
(pulse-audio--message "Volume decreased."))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
2020-08-31 15:53:34 +02:00
|
|
|
(defun pulse-audio-increase-volume ()
|
2019-10-09 13:13:56 +02:00
|
|
|
"Raise the volume output of the default sink."
|
|
|
|
(interactive)
|
2020-08-31 18:05:31 +02:00
|
|
|
(prelude-start-process
|
2020-08-31 15:53:34 +02:00
|
|
|
:name "pulse-audio-increase-volume"
|
2020-09-01 00:28:47 +02:00
|
|
|
:command (string-format "pactl set-sink-volume @DEFAULT_SINK@ +%s%%"
|
2020-08-31 15:53:34 +02:00
|
|
|
pulse-audio--step-size))
|
|
|
|
(pulse-audio--message "Volume increased."))
|
2019-10-09 13:13:56 +02:00
|
|
|
|
|
|
|
(provide 'pulse-audio)
|
|
|
|
;;; pulse-audio.el ends here
|