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.

  • You mentioned the exact programs that should do you what you want. I am not sure what you mean by nothing came as expected. Perhaps you should create a script that you run when required... – user680858 May 18 '17 at 12:58
  • I'm sorry, I don't know how to create scripts. I barely can manage commands. Those I listed are commands found, used mostly to read info about the volume/device/driver, or change the dB volume, but can't limit it permanently. – user690527 May 18 '17 at 13:04
  • No problem, putting the proper commands in a script is no problem. It is just surprising that when you change the values with the Volume Control tool they somehow change back... Unfortunately I cannot replay your configuration as the headphones port is not working in my laptop. – user680858 May 18 '17 at 13:15
  • No problem, I'm keep researching a little bit and the problem lies in alsamixer. PCM=100 and Front=100 are desired values. On the other side if Master goes up more than 30... starts getting really loud. I'll try to find options to limit Master. – user690527 May 18 '17 at 13:24
  • Perhaps you can play with these settings: Increase volume by 5% amixer -D pulse sset Master 5%+ Decrease volume by 5% amixer -D pulse sset Master 5%- Set volume to 50% amixer -D pulse sset Master 50% – user680858 May 18 '17 at 13:30
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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy