Set or limit maximum volume output
Andrew Henderson
Is there a way to limit the maximum volume in Ubuntu? Either in the system configs or terminal CLI? Sometimes I'll accidentally press the volume up button on my computer and raise the volume to ear drum breaking levels and I'd like to not accidentally rupture my ear drums
OS: Ubuntu 20.04 64bit
02 Answers
In the Sound settings panel, confirm that Over-Amplification is disabled... and if you're using external amplified speakers, reduce the physical volume setting there also...
2Not sure if this will help, but if you can't find a better answer, you can always disable your volume keys temporarily using xmodmap.
When I run xmodmap -pke | grep -i volume in terminal, I can find the codes for the keys that control volume in my device:
keycode 122 = XF86AudioLowerVolume NoSymbol XF86AudioLowerVolume
keycode 123 = XF86AudioRaiseVolume NoSymbol XF86AudioRaiseVolumeAfter that, it's just a matter of setting these keycodes to NoSymbol:
xmodmap -e "keycode 122 = NoSymbol"
xmodmap -e "keycode 123 = NoSymbol"This will disable the keys until you turn off your device. To make the change permanent, make it into an executable bash script by saving it as a text file, then running chmod +x myFileName, and finally adding it to your "Startup Applications" (this is an app in your version of Ubuntu).
For the record, to re-enable the keys you would need to re-establish the default values of those keys:
xmodmap -e "keycode 122 = XF86AudioLowerVolume NoSymbol XF86AudioLowerVolume"
xmodmap -e "keycode 123 = XF86AudioRaiseVolume NoSymbol XF86AudioRaiseVolume"Or, you know, just remove the script from the startup apps (if there is one) and reboot your device.
1