Trouble Defining Hotkeys

Recently Linux desktops have made a lot of progress, but since they are always in a state of flux it can be difficult to find a universal way to map keys to programs. Enter xbindkeys a quick and dirty way of adding hotkeys even if your desktop doesn’t support it.

First, you’ll need to obtain the xbindkeys executable. I like to build mine from source. The code for xbindkeys is extremely small. You can obtain it at http://hocwp.free.fr/xbindkeys/xbindkeys.html

Extract the files then go through the usual cycle

configure
make
make install

They also have Debian and Redhat packages although I had dependancy problems with libc on Redhat 7.3 so source worked better for me.

Now to configuration. The website above will have a couple of simple example files. The general idea is to capture X key events before your desktop and window manager ever see them. You can run xbindkeys –key to have xbindkeys output these values for a single key.

1 Next create a .xbindkeysrc file in your user’s home directory. The format is really straightfoward. Put the command line in quotes on one line and then one the second line indent and list the key that executes it. For example to have my calculate key open the xcalc I use:

"xcalc &"
    m:0x0 + c:161

Then just run xbindkeys and voila. Your keys are mapped. You may want to find a permanent way to always run xbindkeys when you start X. I add mine to the start of my gnome-session, but to each his own.

Leave a Reply

Your email address will not be published. Required fields are marked *