I want to make a keyboard shortcut that changes the volume with exactly the same behaviour as pressing one of the default volume keys (up, down, mute), including the OSD notification and the "pop" sound. Right now, my bodged method is to have xdotool
press the volume key, but it would be simpler to find the command the default volume keys send when pressed.
I don't want to use unity-control-center
to reassign the volume keys, because I want to leave the default volume keys in place.
Personally, I use two shortcuts , one bound to CtlrAltArrow Up for volume up and CtlrAltArrow Down for volume down, which you can set in Settings -> Keyboard -> Shortcuts -> Custom.
Shortcuts are bound to two script files, given full path (though you don't have to place the commands bellow into scripts necessarily ).
For volume up, the command in script file is:
And for volume down the other command is
As you can guess, the two commands raise and lover volume in increments of 10 depending on your sound card. You can also use
10%+
to increase volume up 10% from what the current value is, but keep in mind that when decreasing the volume, the current value will get smaller and smaller, so it will be difficult to raise it back from smaller number (because 10% of small number will also be small)