gconftool-2 + xvkbd = Custom keyboard shortcuts in any application
I'm using gthumb as a simple image organization tool. It has the basic viewer, slide show, and even image manipulation functions. Furthermore, it allows you to catalogue files in virtual folders (libraries and catalogues). However, the way to add a picture to a catalogue is tedious: Select a picture, click the Edit-menu, click "Add to Catalogue", and OK in the appearing window. If you're adding many pictures, you'll have to repeat this many times. Unfortunately, gthumb does not provide a shortcut for this. So I made my own.
Using gconftool-2, I assigned a command to the key-combination CTRL + ALT + B:
gconftool-2 -t str --set /desktop/gnome/keybindings/custom1/name "Gthumb - Add to catalogue"
gconftool-2 -t str --set /desktop/gnome/keybindings/custom1/binding "<CTRL><ALT>b"
gconftool-2 -t str --set /desktop/gnome/keybindings/custom1/action "xvkbd -text '\D5\Ae\D1a\D3\r'"
The vital bit is the xvkbd command, which can send keyevents to any window. In my example, I insert a few delays: \D5 = 500ms, press ALT+E (\Ae), press a, and finally hit Return (\r). The delays were necessary since I choose the triggering binding to include the ALT key as well. I have to give myself enough time to let go of the ALT key before I fire it again.
If you need more key bindings, make sure to increase the number after custom, e.g. custom2, custom3.
Also note, the shortcut will be active in all applications, so in the terminal window, the effect will be: Select All, and Enter.
To install xvkbd:
Download from http://homepage3.nifty.com/tsato/xvkbd
yum install imake libXaw-devel libXtst-devel Xaw3d-devel
[...]
xmkmf; make install install.man