16

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?

3
  • Use "Custom shortcuts" under "Keyboard shortcuts"
    – Hatshepsut
    May 10, 2018 at 19:10
  • 1
    Yes, you can assign multiple keyboard shortcuts for the command in Ubuntu 18.04. askubuntu.com/questions/59250/… (I couldn't post an answer here since this question was closed as duplicate).
    – wisbucky
    Dec 4, 2018 at 21:38
  • For a GUI-based solution, similar to @wisbucky's comment, you can install dconf-editor. sudo [apt|dnf] install dconf-editor. See ar.al/2019/03/11/…. Sep 18, 2020 at 16:06

2 Answers 2

7

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).

4
  • 3
    Ubuntu 16.04: doesn't seem to work, I can set multiple values like this but only the first one has an effect Nov 27, 2016 at 15:20
  • 2
    Ubuntu MATE 16.04, same story - no error, no work. Go figure. Jun 26, 2017 at 20:12
  • 2
    Works on Arch Linux. Similar Q/A with a screenshot for the dconf GUI here: unix.stackexchange.com/questions/361551/…
    – SimonG
    May 31, 2018 at 19:56
  • This doesn't appear to work for media keys, which don't accept an array. But it works for combinations such as '<Alt>Escape'. See my comments and @wisbucky's comments under OP's question. Sep 18, 2020 at 16:09
6

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

2
  • 2
    Yes, you can assign multiple keyboard shortcuts for the same command, even though the Settings GUI doesn't let you. Tested on Ubuntu 18.04. askubuntu.com/questions/59250/…
    – wisbucky
    Dec 4, 2018 at 21:39
  • I can also confirm with Fedora 34 and Gnome 40 adding more keybindings with the dconf editor works like a charm. It's just that the default gnome keyboard shortcuts editor doesn't support more than one.
    – Timo
    Oct 16, 2021 at 9:45

Not the answer you're looking for? Browse other questions tagged .