Assign multiple keyboard shortcuts for one action

You can assign multiple keyboard shortcuts (keybindings) for the same command using gsettings command line.

One important thing to know is that Ubuntu 18.04 Settings GUI only shows the first keybinding for a command, so if you have multiple keybindings for a command, the others won't appear in Settings. You can use gsettings to all the keybindings.

Let's say I want to add another keybinding for "Switch to Workspace 1". The default for me was Super+Home, but I want to add a second keybinding Ctrl+1.

# list all keybindings
gsettings list-recursively | grep -e org.gnome.desktop.wm.keybindings -e org.gnome.settings-daemon.plugins.media-keys -e org.gnome.settings-daemon.plugins.power | sort 

# confirm no other keybinding conflicts
gsettings list-recursively | grep '<Control>1'

# set multiple keybindings for "Switch to Workspace 1"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-1 "['<Super>Home', '<Control>1']"

# confirm value is set correctly
gsettings get org.gnome.desktop.wm.keybindings switch-to-workspace-1

Now you can use either Super+Home or Control+1 to Switch to Workspace 1. Remember, you will only see the first one Super+Home in the Settings GUI, but it will work!


I do just that with Custom Shortcuts:

screenshot of keyboard shortcuts settings

I use xdotool key --clearmodifiers XF86AudioLowerVolume (and XF86AudioRaiseVolume) command instead of amixer set 'Master' 10%+. The only difference/downside I notice is that even Repeat Keys on Typing tab is set this doesn't apply to this custom shortcut.

However, I wasn't able to do some things like use Fn+F7 to turn off my screen (xset dpms force standby). It doesn't detect it as a shortcut event.


You could probably use xmodmap to reassign the buttons on your headset to the same as you use for your keyboard.


update for ubuntu 20


have to say those days, dconf-editor is very easy to use, really nice.


0. preview

workspace up

workspace down


1. location input

folder too deep ? copy & paste location.

  • click title bar 🔍 or
  • Ctrl + F or
  • Ctrl + L
    to active localtion bar input:
/org/gnome/desktop/wm/keybindings/switch-to-workspace-up
/org/gnome/desktop/wm/keybindings/switch-to-workspace-down

dconf_location


2. search in folder

many items in folder? search it.

NOTICE: this is different with Ctrl + F

search_0

search result:

search_1


3. bookmark

mark the location you often use.

bookmark


4. changes

Before applying the modifications, It even intimately shows the difference.

changes


5. default value

you can use default value,
and keep your changes in setting (but not effective )

//Refer the previous img.




It's awesome, perfect user experience 👍