Multimedia keyboards: uhidd/xbindkeys/xmodmap

Table of Contents

uhidd: The driver
xbindkeys: Create hotkeys
xmodmap: Remap the keys

xbindkeys: Create hotkeys

by ross at 06:32:26 on December 4, 2012

Install

# cd /usr/ports/x11/xbindkeys
# make install clean

Initialize

> cd
> xbindkeys --defaults > .xbindkeysrc

Now edit .xbindkeysrc and comment out the example bindings.

Create hotkeys

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>"

 

Comments