APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed

X hotkeys with xbindkeys

by Girish Venkatachalam

Girish Venkatachalam is a UNIX hacker with more than a decade of networking and crypto programming experience. His hobbies include yoga,cycling, cooking and he runs his own business. Details here:



xbindkeys is very easy to use when you wish to bind hotkey presses on X sessions. Either when you are on a xterm or otherwise. You have be within the Xwindow session, that is all. Typical Xwindow sessions span multiple virtual displays or workspaces and typically on linux you have Xwindow running on virtual terminal Alt + Ctrl + F7. Anyway I think you know what I mean.

I created a default keybindings file with

$ xbindkeys --defaults > $HOME/.xbindkeysrc

The syntax is braindead simple.

  Control + b2 + Release

If you want to invoke pidgin when you press Ctrl key on the keyboard with the second mouse button.

But things get complicated. You have to know keycodes. You can easily find that by running

$ xbindkeys -k

It throws up a small white screen a la xev and you will know which keycode corresponds to which key.

After that just start the xbindkeys daemon with

$ xbindkeys

Every time you change a binding you have to restart this daemon or send the HUP signal.

$ pkill -HUP xbindkeys

I find that you can create a long command as a shell script and then bind it. That is more useful to me from a practical point of view.

For instance,

I create a /bin/playaudio file like this.

   mplayer /home/music/file1.mp3

And then chmod it.

# chmod +x /bin/playaudio

Then configure xkeybindings file like this.


 Mod_M + b1

This will play a song when I press the useless Windows key along with mouse button 1.

Please refer to the command I gave above to figure out keycodes and keynames. It is very useful.

Got something to add? Send me email.

Increase ad revenue 50-250% with Ezoic

More Articles by © Girish Venkatachalam

Kerio Samepage

Have you tried Searching this site?

Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us

Dump may work fine for you a thousand times. But it _will_ fail under the right circumstances. And there is nothing you can do about it. (Linus Torvalds)

This post tagged: