2

I want to be able to change the volume from a range of 0% to 40%. Cap it there permanently.

Sometimes depending on the program I'm running, the audio get resetted resulting in a full blast of 100% volume in my headphones.

I tried using different commands. pactl, pacmd, and sink-volume commands, but nothing came as expected.

Thanks in advance if anyone knows how to do this! Google doesn't give out any solution as I've searched a lot.

1 Answers1

0
#!/bin/bash
Lines=$(amixer -D pulse sget Master | grep '[0-9]%' | awk '{printf "%s\n",$5}')

set -- $Lines
lVol=$(echo "$1" | tr -cd [:digit:])
rVol=$(echo "$2" | tr -cd [:digit:])

if ((lVol>rVol))
then hVol=$lVol
else hVol=$rVol
fi

maxVol=40
if ((hVol>maxVol))
then
  echo "One or both channels too loud, setting both to $maxVol"
  amixer -D pulse sset Master ${maxVol}%
fi
# EOF #