xbindkeys: Create hotkeys
# cd /usr/ports/x11/xbindkeys # make install clean
> cd > xbindkeys --defaults > .xbindkeysrc
Now edit .xbindkeysrc and comment out the example bindings.
First, identify the target key:
> xbindkeys -k
Wait for a small window to appear. Now press the key you want to use. For instance, this is my “calculator” multimedia key:
> xbindkeys -k Press combination of keys or/and click under the window. You can use one of the two lines after "NoCommand" in $HOME/.xbindkeysrc to bind a key. "(Scheme function)" m:0x10 + c:191 Mod2 + NoSymbol
The first indented line is the data you need (m:0x10 + c:191). Add to ~/.xbindkeysrc:
# Calculator "galculator" release + m:0x10 + c:191
galculator is the name of an executable file.
You are not limited to simple commands only — any shell command will work, including pipes and redirects:
# Radio: Skip the song "echo 'skip' | nc localhost 54311" release + m:0x10 + c:210
If you want to simulate a key press install x11/xdotool. For example, this hotkey simulates Alt-Tab:
# Compiz: ShiftSwitcher - Initiate (all workspaces) "xdotool key alt+Tab" release + m:0x10 + c:92
But wait! If all you want to do is to map key presses to another keys then xmodmap (next page) is the tool you need. It works faster and better than "xdotool key <the_key>"