7

Is it possible to set an upper limit for PulseAudio on startup? I would like to make sure that I do not put the volume too high for the sake of my eardrums.

I looked into pactl set-sink-volume but that doesn't allow me to set a maximum volume limit. As well I cannot find anything under man pactl.

  • Here is another person asking the same question (also unanswered, unfortunately): https://unix.stackexchange.com/questions/188808/set-maximum-volume-in-arch-linux — there is a cheap hardware solution, though. – derobert May 15 '17 at 15:42

1 Answers1

5

You can do it by the following bash code

#!/bin/bash
x=$(pactl list sinks | grep '^[[:space:]]Volume:' | head -n $(( $SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,' )
if [[ $x -le 200 ]]
then
    pactl set-sink-volume 0 +5% 
fi

In this volume is stored in variable x