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.
"pidgin" 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
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.
I create a /bin/playaudio file like this.
#!/bin/sh mplayer /home/music/file1.mp3
And then chmod it.
# chmod +x /bin/playaudio
Then configure xkeybindings file like this.
"playaudio" 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.
More Articles by Girish Venkatachalam © 2009-11-07 Girish Venkatachalam
When someone says: "I want a programming language in which I need only say what I wish done", give him a lollipop. (Alan J. Perlis)