Showing posts with label shortcuts. Show all posts
Showing posts with label shortcuts. Show all posts

Monday, February 7, 2011

How to Assign/Remap Keyboard Shortcuts For Better Productivity [Linux]

remap-key-mainBy default, Ubuntu comes with a set of keyboard shortcut that you can use straightaway. However, some of these keyboard shortcuts might not be desirable, troublesome, or obstructive and disrupting your productivity. For example, if you have a keyboard with a media button, that button is automatically mapped to Rhythmbox. If your favorite media player is Banshee, or Exaile, you might want to change the keyboard shortcut to your favorite application.

There are several ways to manage your keyboard shortcut in Linux. You can do it via Xmodmap (and Xkeycaps), Gnome Keyboard Shortcut or Compiz. In this article, we will focus mainly on Gnome Keyboard Shortcut and Compiz.

Gnome Keyboard Shortcut

The Gnome keyboard shortcut is by far the easiest way to assign/remap a shortcut key in any Gnome-based distro. Go to System -> Preferences -> Keyboard Shortcuts.

remap-key-gnome-keyboard-shortcut

From here, you can scroll down the list to find the particular keyboard shortcut you want to change, click on the existing shortcut (and see the entry change to “New Shortcut”), and press the new keyboard shortcut that you want to assign to. For example, the default shortcut to launch the Run Application dialog is “Alt + F2“. If I want to change it, I will click on the Alt + F2 entry, follow by the new key, say “Alt + F12“.

remap-key-gnome-change-shortcut

remap-key-gnome-new-shortcut

remap-key-gnome-changed-shortcut

In addition, you can also create your own keyboard shortcut and assign it to run an application, a command or a script. Click the “Add” button. It will prompt you to enter the name and command.

remap-key-gnome-create-new-shortcut

After you have added the command, you will see a new entry with the shortcut field “Disabled”. Click on it.

remap-key-gnome-new-shortcut-disabled

Press the keyboard buttons that you want to assign to launch this command. That’s it.

remap-key-gnome-assign-shortcut

You can also use the above method to overwrite a default shortcut key. For example, the default behavior of the “Delete” button in your keyboard is to move your file to the trash. You can, however, create a new shortcut and map the “Delete” button to shred the file beyond recovery. It will overwrite the default behavior.

Note: If you want to remove the overwrite, you can remove the shortcut entry and restart your current session (logout and login again). The default behavior will restore.

Compiz

Compiz is slightly more complicated than Gnome Keyboard Shortcut, but it is more versatile and give you more option.

Before we start, make sure you have Compiz Config Setting Manager installed, either from Ubuntu Software Center or from the terminal:

sudo apt-get install compizconfig-settings-manager

Launch Compiz Config Settings Manager (System -> Preferences -> CompizConfig Settings Manager)

Click the “Commands” option.

remap-key-compiz-command

Enter the command in the command field. It can be an application, a command or even a path to script.

remap-key-compiz-enter-command

Next, go to the Key Bindings tab. Click the “Disabled” button for the command line that you have entered just now.

remap-key-compiz-disable-button

Check the “Enabled” checkbox and click the “Grab key combination” button. Press the keyboard shortcut and add any modifier key (Ctrl, Shift or Alt) if necessary. Click OK.

remap-key-compiz-set-shortcut

That’s it. What other ways do you use to assign/remap keyboard shortcuts in your distro?

Image credit: Mike Traboe

Posted via email from ://allthings-bare

Tuesday, August 31, 2010

Assign a Shortcut Key to Activate an Open Application Window on Linux

We’ve already shown you how to customize shortcut keys in any Linux application, but for today’s lesson we’ll take it a step beyond—and assign a shortcut key that switches an open application to be the currently focused window.

The idea is that instead of using the mouse or flipping through a set of windows in the Alt+Tab switcher, you can quickly assign a hotkey to your most important windows and switch to them with a single keystroke, saving yourself a lot of time. To accomplish this task on Linux, we’ll use the excellent AutoKey utility.

Note: if you want the Windows way to do this, you can accomplish the task with AutoHotkey easily.

The Scenario

Since I do most of my work in Google Chrome, I need to have it accessible as quickly as possible and I generally assign the Alt+G key combination to switch to my open Chrome window.

image

Installing AutoKey

You’ll want to open up the Synaptic Package Manager and do a quick search for autokey, check the box, and then install the package. You could also install it using the apt-get command like this:

sudo apt-get install autokey

image5

Assigning a Shortcut Key to an Application Window

Open up the AutoKey configuration screen from the system tray icon, and then create a New Script from the menu, and then paste in the following code:

window.activate(‘Google Chrome’)

You’ll want to use the Set button next to the Hotkey setting, and assign your preferred hotkey—mine is Alt+G, though you’ll want to make sure that you use a lowercase g while setting the hotkey—if you set it using an uppercase letter it won’t behave right.

image

Once you save the setting and minimize or close the AutoKey configuration screen, you can hit the Alt+G shortcut key combination anytime you want to switch to the open window.

How Does This Work?

When you hit the shortcut key that you’ve assigned, AutoKey will run the script that you’ve added—in this case, it’s a simple Python script that uses the wmctrl functions to control open windows. Here’s the syntax for the window.activate function, which switches the specified window to be the active window:

window.activate(‘partial window title here’)

Basically all you need to do is match part of the window title, and in the case of Google Chrome, the window title always has “- Google Chrome” at the end.

Posted via email from ://allthings-bare