Multiple keyboard shortcuts for same command [duplicate]

Is it possible to assign multiple keyboard shortcuts for same default command. I want to switch between workspaces using CTRL+NUMPAD_1 and using CTRL+1 too.

Or how to add custom command for switching?


Solution 1:

Stephan's Answer which is quoted in Lambart's answer was updated and now has a very interesting side-note:

I also found out that the GUI that allows you to assign keybindings is limited in a way that annoys me. The GUI allows exactly ONE keybinding to be assigned to each action. In dconf, you can set an array of bindings for a single action.

Quick research lead me to Ubuntu's Wiki:

The keybindings that are handled by the window manager support multiple keys that will perform the same action. The gnome-control-center GUI does not support it, but you can make it work using dconf-editor. For example to have "Close window" use both the traditional F4 as well as an easier to hit Pause/Break button, change org.gnome.desktop.wm.keybindings close to ['Pause', 'F4'].

Anyway my attempt to set volume control to CTRL+SUPER++ and my laptop's media key via

gsettings set org.gnome.settings-daemon.plugins.media-keys volume-up ['<Primary><Super>KP_Add', 'XF86AudioRaiseVolume']

results in an error for invalid value while wrapping the array in quotes does not trigger an error but assigns no function to any of the keys neither. (I assume Ubuntu 12.04 might not having received an update in this regard).

Solution 2:

I spent a while looking into this, and unfortunately the answer seems to be "no".

Stephen Ostermiller did some excellent research into keyboard shortcuts, which you can read in his answer, here: Where are GNOME keyboard shortcuts stored?

That led me to the dconf-editor utility, where I found the relevant settings:

dconf-editor screenshot

As you can see, my preferred shortcuts for switching workspaces are Alt1, etc. The square brackets around the Value led me to think that it might allow an array of values, but I although I was able to change the shortcuts via this value, was unable to get more than one to work. It would only use the first which one I defined.

But for anyone who finds this answer while trying to figure out how to set shortcuts for switching workspaces, I should point out that the easiest way to do it is via the GUI. In Unity, bring up the System Settings editor and navigate to Hardware > Keyboard > Shortcuts > Navigation. You'll find instructions at the bottom of the window:

enter image description here