If you're anything like me, you hate taking your fingers away from the keyboard. It's inefficient and clumsy. Fortunately, the Linux desktop allows you to configure keybindings (a.k.a. shortcuts) that will alleviate most of your movements from the keyboard so you can work like the efficient beaver that you are.
In this Linux Desktop Invasion, I'll show you how to configure keybindings for different actions. For simplicity’s sake, I’ll be sticking to the two most widely distributed desktop environments: GNOME and KDE.
Keybindings in GNOME
To add or remove keybindings in GNOME, I’ll work through the GNOME Control Center (run command: gnomecc). In this tool, under Sawfish, I’ll find the Shortcuts section (see Figure A) where I’ll be able to add, edit, and delete shortcuts to my heart’s content.
|From the top drop-down box, I can select from Global shortcuts, which affect the entire desktop; Window shortcuts, which affect any window that has focus; or Title shortcuts, which affect the titlebar of a window.|
The first shortcut I’ll create will be to run the Evolution groupware suite from Ximian. Because there’s no default shortcut for Evolution, I’ll have to create one.
First, from within the Shortcuts window, I’ll click Add. When the Add window appears, I’ll scroll down and select Run Shell Command (see Figure B).
|From the Add window, you can add anything from Activate Viewport to Xterm.|
I’ll enter the proper command in the Command box (for my example, I’ll enter evolution). The next step is to determine a good shortcut for the action. This is an important step that should take some thought. When I first set up my Evolution shortcut, I configured it to use the key combination [Ctrl]E. This combination worked fine, except for one little conflict. You see, when running Evolution, if you want to expunge (move deleted e-mail to the trash), you use the key combination (you guessed it) [Ctrl]E. Needless to say, every time I went to expunge my e-mail, I opened another instance of Evolution. Back to the drawing board for me. Fortunately, I rarely use that Windows key on my keyboard for anything, so I have my key combination. (You see, there is a use for everything.)
To add this key combination, I can do one of two things. The first way to add a key combination is to press the Grab button, which will display a small dialog box (see Figure C). I’ll press the key combination and press OK to return to the main Shortcuts window. From here, I can either press Try (to apply the shortcut but keep the Shortcuts window open) or I can press OK (to apply the shortcut and close the Shortcuts window). Now when I press the Windows key and the E, Evolution will start.
|Make sure you press the correct key combination, or you'll be starting over.|
Daemon tails and keyboards
I can also start a daemon (so long as a standard user has permission to start that particular daemon) with a keybinding. Let's say I want to be able to start my fetchmail daemon with a simple key combination. Instead of having to open a terminal, type fetchmail -d 120, and press [Enter], I want to press the Windows key and the F key together.
To accomplish this, I’ll run through the same steps I did for the Evolution shortcut, only I’ll press the Windows key and the F for the key grab and I’ll enter the command fetchmail -d 120 in the Command field. Now with this shortcut in play, I can start my fetchmail daemon without moving my hands from the keyboard. We're getting much more efficient now.
Let's say I want to run the tail -f command to follow the last 10 lines of the /var/log/messages file. Of course, to do this I need root permissions, so I have to be a bit tricky with the command. I run through the same setup as earlier outlined, choose a key combination of the Windows key and the T, and then enter the following command in the Command section:
terminal -e 'su - root -c "tail -f -n 10 /var/log/messages"'
Now when I press the Windows key and the T, a gnome-terminal will start up asking for the root password. After entering root's password and pressing [Enter], I’ll see the tail output of the last 10 lines of the /var/log/messages file. Handy, don't you think?
The KDE keybindings are not quite as configurable as the GNOME keybindings, but knowing the basic sets will help to make your computer work much more efficient.
To work with the KDE keybindings, you need to open the KDE Control Center (from the K menu, click on the Control Center entry) and navigate to Key Bindings through the Look & Feel entry (see Figure D).
Click on the Key Bindings entry to open what is shown on the right side of Figure D. As you can see, a number of actions with preconfigured key bindings are ready to use. Some of these actions don’t have key bindings attached. For instance, the Switch One Desktop To The Right entry is very handy; it lets me move to the desktop to the right of the one I’m working on. The KDE team hasn’t assigned it a key binding. Let's give it one.
To assign a key binding to this action, I’ll highlight the action, click the None button below it, and then press the [Ctrl][Alt]Right Arrow key combination. The final step is to click Apply. When I press [Ctrl][Alt]Right Arrow from now on, I’ll be zapped to the desktop to the right.
Unfortunately, I’m not able to assign a key combination to a specific command. I can open an Execute Command window, which will allow me to enter a command, but I’ll have to enter that same command every time I want it to run. So, if I wanted to run my gnome-terminal -e 'su - root -c "tail -f -n 10 /var/log/messages"' command, I would have to enter the key combination to open the Execute Command application (by default, it’s [Alt][F2]) and then type in the command. This isn't nearly as simple as in GNOME, but it still works to keep your hands on home row, so to speak.
Making the Linux desktop efficient is one of the many joys of using this open source operating system. You can expand this project beyond the desktop into the application space and create key bindings for many Linux applications. Not only does it make your work much more efficient, it allows you to take total control over your desktop.
Do you enjoy the Linux Desktop Invasion? Send Jack a note and tell him what you’d like to know about this amazing desktop.
Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website getjackd.net.