aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoni Rabkin <yoni@rabkins.net>2017-06-19 14:55:40 -0400
committerYoni Rabkin <yoni@rabkins.net>2017-06-19 14:55:40 -0400
commit0ebffc0b7263d261c9de1f117a96d28447889dfd (patch)
tree96f91b54caee602f446c285996ef5c0f230862be
parent0481ca3b8f8d558e545582440dde6dac514818fe (diff)
* lisp/emms-volume.el: Limits volume percentages
Limits volume percentages between 0 and 100 by default. At least with the Solaris sink, attempting to set a volume outside this range will fail with a "connection terminated" error from pactl. trivial patch by David Michael <fedora.dm0@gmail.com>
-rw-r--r--lisp/emms-volume-pulse.el19
1 files changed, 8 insertions, 11 deletions
diff --git a/lisp/emms-volume-pulse.el b/lisp/emms-volume-pulse.el
index 8d95e30..7fc6de5 100644
--- a/lisp/emms-volume-pulse.el
+++ b/lisp/emms-volume-pulse.el
@@ -56,13 +56,9 @@ See full list of devices on your system by running
(string :tag "Sink symbolic name"))
:group 'emms-volume)
-(defcustom emms-volume-pulse-max-volume 150
- "The sink to use for volume adjustment.
-
-See full list of devices on your system by running
- pactl list short sinks"
- :type '(choice (number :tag "Sink number")
- (string :tag "Sink symbolic name"))
+(defcustom emms-volume-pulse-max-volume 100
+ "The maximum volume percentage."
+ :type 'integer
:group 'emms-volume)
@@ -73,7 +69,7 @@ See full list of devices on your system by running
(output
(shell-command-to-string
(concat "pactl list sinks" "|"
- "grep -E -e 'Sink' -e 'Name' -e '^[^a-zA-Z]*Volume'"))))
+ "grep -E -e 'Sink' -e 'Name' -e '^[^a-zA-Z]*Volume'"))))
(string-to-number
(car
(reverse
@@ -97,12 +93,13 @@ See full list of devices on your system by running
;;;###autoload
(defun emms-volume-pulse-change (amount)
- "Change amixer master volume by AMOUNT."
+ "Change PulseAudio volume by AMOUNT."
(message "Volume is %s%%"
(let ((pactl (or (executable-find "pactl")
(error "pactl is not in PATH")))
- (next-vol (min (+ (emms-volume--pulse-get-volume) amount)
- emms-volume-pulse-max-volume)))
+ (next-vol (max (min (+ (emms-volume--pulse-get-volume) amount)
+ emms-volume-pulse-max-volume)
+ 0)))
(when (zerop (shell-command
(format "%s set-sink-volume %s %s%%"
pactl emms-volume-pulse-sink next-vol)))