How do I set a custom keyboard shortcut to control volume?
Solution 1
@dobey's solution works if you want to have only one keyboard shortcut for increasing / decreasing the volume.
If instead you want to have multiple key bindings controlling the volume (like to keep the default volume buttons on your laptop working, while adding additional keyboard shortcuts to use when you connect an external keyboard that does not have volume controls), then:
-
Go to System Settings → Keyboard → Shortcuts → Custom Shortcuts.
-
Click
+
to add a new keyboard shortcut. Set the "Name" toVolume up
, "Command" toamixer -D pulse sset Master 5%+
and clickApply
. -
Click
Disabled
next to your new key and choose the desired binding on your keyboard. -
Add another shortcut with name
Volume down
and commandamixer -D pulse sset Master 5%-
Solution 2
Open System Settings
, go to Keyboard
, then the Shortcuts
tab, and finally choose Sound and Media
in the list on the left. You can then choose the Volume related items in the list on the right side, and select which keybinding to use.
(Reverse usage of left and right here, for RTL languages.)
Solution 3
Usually, this command works just fine as a command for lowering the volume (Ubuntu 16.04):
amixer -q -D pulse sset Master 5%-
On Ubuntu 18.XX (Gnome) escape the %
symbol:
amixer -q -D pulse sset Master 5%%-
Worked for me!
Related videos on Youtube
max
Updated on September 18, 2022Comments
-
max over 1 year
I would like to be able to set three custom keyboard shortcuts to be able to decrease, increase and mute the volume in Ubuntu 12.04 (Unity). On my old Ubuntu 10.04 (Gnome) system I made CTRL + [, CTRL + ] and CTRL + \ my commands to achieve this.
What is the simplest way to go about this?
-
CivMeierFan over 8 years+1 Good magic - it works. It would be nice if it tied into the same volume bar that pops up with the regular volume buttons.
-
CivMeierFan over 8 yearsmute/unmute:
amixer -D pulse sset Master toggle
-
user10853 over 7 yearsI used your commands but the Volume up shortcut actually lowers the volume instead though it works normally in the terminal. What's going on?
-
Anis Abboud over 7 yearsMake sure you typed
5%+
not5%-
for volume up. -
user10853 over 7 yearsYes I confirm I had those right @AnisAbboud
-
Arkya over 7 yearsworks for me on 14.04 as well ..+1
-
CivMeierFan almost 7 yearsThe volume up/down shortcuts don't work in Ubuntu 16.04 with Gnome3. The Mute shortcut, however, does. The up/down commands work if I use them in a terminal manually. I noticed the shortcuts instead set the values to 0%, implying a command parsing bug. An imperfect workaround is to use raw values instead -- e.g.
amixer -D pulse -R sset Master 3277+
andamixer -D pulse -R sset Master 3277-
. The actual number may vary depending on your device. My max raw value was65536
. -
CivMeierFan almost 7 yearsThis works, but it also disables the built-in Volume control buttons on my laptop. Anis' answer above allows those to still work.
-
dobey almost 7 yearsThat wasn't a requirement of the question asked, and also depends on how the volume control buttons are implemented. Also, this question is 5 years old, and Ubuntu 12.04 is End of Life now.
-
Ahmad Ismail about 6 years@AnisAbboud I have a similar question related to this question. Can you please check it out askubuntu.com/questions/1038099/…
-
tisaconundrum almost 6 yearsSmall chuckle from for that fantastic "The End"
-
Tobias S over 5 yearsI just want to stress out, that the escaping is only needed for a new hotkey, not on the terminal itself.
-
abu_bua over 5 years
set
? Should besset
, or? -
Fabby over 5 years@abu_bua according to the manual, both
set
andsset
are valid commands on 16.04 (the version I'm running) -
Abhishek Bhatia about 5 yearsIs it possible to do the same thing for media play/pause. What would be command for that?
-
somethis almost 5 yearsA suggestion for non multimedia keybindings: Volume Up
ALT
+PageUp
, Volume DownALT
+PageDown
, MuteALT
+Pos1
. Though it is more of a Windows standard to use the PageUp and Down keys for volume it is mapped in a lot of software, too. Still, Firefox usesSTRG
+Page Up
to switch between Tabs so just useALT
. -
Pablo Bianchi over 4 yearsJFTR, another way would be with the command
xdotool key --clearmodifiers XF86AudioRaiseVolume
-
neo post modern over 4 yearsAs of 19.04 the escaping doesn't seem to be necessary even for the hotkey