Thursday, June 26, 2008

Assigning keyboard shortcuts in Ubuntu

Changing keyboard shortcuts in Ubuntu is fairly easy. First, check a rather limited list of commands by opening System -> Preferences -> Keyboard Shortcuts. If the task you want to assign a keyboard shortcut to is listed, simply change or assign a desired shortcut to the task and you are done. However, if you are like me, it is likely that your desired task (application, script, etc.) is not listed. In this case, you can use the Gnome Configuration Editor.

Let us change the default behaviour of Ctrl+Alt+Delete to open up the System Monitor instead of displaying the logout screen:
  1. Open Keyboard Shortcuts, go to Desktop, and change Log out from Ctrl+Alt+Delete to something else, for example Ctrl+Alt+Home.
  2. Press Alt+F2 and run gconf-editor.
  3. Maneuver to apps -> metacity -> keybinding_commands.
  4. Doubleclick a command key, for example command_1, and enter the command gnome-system-monitor. The full path may be necessary for a script or or other command (e.g., /home/username/myscript.sh).
  5. Maneuver to apps -> metacity -> global_keybindings.
  6. Doubleclick the run key corresponding to the command key in step 4, i.e., run_command_1, and enter the desired keyboard shortcut, Delete.
If you are running Compiz Fusion as your window manager, it may be that you must use the CompizConfig Settings Manager (CCSM) to change the keyboard shortcut. This method is even simpler:
  1. Go to System -> Preferences -> Advanced Desktop Effects Settings and select the Commands tab under General Options.
  2. Select the Commands arrow button and enter gnome-system-monitor in a command line, for example command line 0.
  3. Select the Key bindings arrow button and click the button corresponding to the same run command, i.e., Run command 0. Enable it and enter the desired shortcut key combination.
After completing the procedure above, Ctrl+Alt+Delete will now open the System Monitor, while Ctrl+Alt+Home will show the logout screen.

No comments: