/ tutorial

Adding universal shortcuts in ubuntu/gnome

The default keyboard shortcut application in gnome, as you might have noticed, isn't worth very much. You can only assign keyboard shortcuts to a list of predefined commands. Not very valuable really. It is however possible to define up to 12 custom keyboard shortcuts in a slightly more complicated manner. (Some people have said it's possible to define up to 32 shortcuts, but I haven't been able to define more than 12. If somebody has successfully defined more than 12 please contact me and let me know)

Also it seems that "The common way" and "A slightly different, but perhaps simpler way for some of you" methods I describe here are independent of each other. That means that by combining the two, you can add 24 custom keyboard shortcuts instead of only 12.

Article continues after ad

The common way

  • Hit Alt+F2, enter the command gconf-editor and hit Run to launch the Configuration Editor
  • Navigate to apps->metacity->global_keybindings
  • For each keyboard shortcut you wish to add change the value of one of the run_command_x entries where x is a number between 1 and 12. Metakeys must be inserted between <>. For example the key combination Ctrl+Alt+1 you would enter as <Ctrl><Alt>1. The winkey is Mod4
  • Navigate to apps->metacity->keybinding_commands
  • For each x you changed in the previous step change the value of the command_x key to the command you wish to be run when pressing the keyboard shortcut.
  • The keyboard shortcut should start working instantly.

Example: To make the keyboard shortcut Winkey+e start emacs do the following:

  • Navigate to apps->metacity->global_keybindings
  • Change the value of the run_command_1 entry to <Mod4>e
  • Navigate to apps->metacity->keybinding_commands
  • Change the value of the command_1 key to /usr/bin/emacs

A slightly different, but perhaps simpler way for some of you

If you happen to use compiz you can do the same with an interface that might make a little bit more sense and be easier to use for "novice" computer users.

  • Start the System->Preferences->Advanced Desktop Effects Settings application.
  • Navigate to the Commands tab.
  • Here you can enter the same settings as above, but you can grab the keyboard shortcut directly from the keyboard. No need to remember all of those nasty metakeys and stuff.

The hardcore way

If you consider yourself hardcore, are GUI impaired, or just fancy doing everything by editing XML files you can add keyboard shortcuts by editing the following two XML files:

~/.gconf/apps/metacity/global-keybindings/%gconf.xml ~/.gconf/apps/metacity/keybinding_commands/%gconf.xml
If this is an option for you, you will not need any help doing this or figuring out the syntax of the XML files, so I'll give no description here.

Photo by Taduuda / Unsplash