Skip to Content

ThinkPad USB Keyboard with TrackPoint

Posted on

A Thinkpad keyboard minus the Thinkpad with the classic Trackpoint + Left/Middle/Right mouse buttons. Its attached to my desktop and I want to change the behaviour of a few keys.

Let’s go!

Attach the keyboard …

lsusb | grep -i keyboard
    Bus 001 Device 002: ID 17ef:6009 Lenovo ThinkPad Keyboard with TrackPoint

0. Caps_Lock and xmodmap

Caps_Lock occupies a prime location and - seeing as I do not carry on many ALL CAPS conversations - the key can be re-purposed for better use. I use xmodmap to modify the keymap and transform the key into BackSpace.

Retrieve current keymap (and the keycode for Caps_Lock) …

xmodmap -pke
    [...]
    keycode  66 = Caps_Lock NoSymbol Caps_Lock
    [...]

Output for Caps_Lock using xev

KeyPress event, serial 32, synthetic NO, window 0x1600001,
    root 0xb4, subw 0x0, time 578277182, (137,-6), root:(781,12),
    state 0x0, keycode 66 (keysym 0xffe5, Caps_Lock), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

Test a new key modification in the current Xsession …

xmodmap -e "keycode 66 = BackSpace" && xmodmap -e "clear Lock"

Make the change sticky by adding the keymapping to ~/.xmodmap

! Modify Caps_Lock into Backspace                                                  
keycode 66 = BackSpace                              
clear Lock

Modify ~/.xinitrc to load keymap at startx

if [ -f ~/.xmodmap ]; then
    xmodmap ~/.xmodmap
fi

… and apply the new settings in the current session ..

xmodmap ~/.xmodmap

1. Multimedia keys and xbindkeys

This keyboard includes multimedia keys. Create keyboard shortcuts for these specialty keys by installing:

  • xbindkeys - associate keys to shell commands
  • pulseaudio-utils - manage sound with pactl
  • rhythmbox-plugins - (optional) player controls
sudo apt install xbindkeys pulseaudio-utils rhythmbox-plugins

With rhythmbox-plugins the Fn+{Play,Pause,Previous,Next,Stop} controls “just work” with the audio player. I use xbindkeys to associate new functions to keys.

Retrieve the keycodes and keysyms of the volume keys …

xmodmap -pke | egrep -i 'volume|mute'
    keycode 121 = XF86AudioMute NoSymbol XF86AudioMute
    keycode 122 = XF86AudioLowerVolume NoSymbol XF86AudioLowerVolume
    keycode 123 = XF86AudioRaiseVolume NoSymbol XF86AudioRaiseVolume
    keycode 198 = XF86AudioMicMute NoSymbol XF86AudioMicMute

I create a standalone script to control PulseAudio volume and associate the new command paVolume and its options to volume keys in ~/.xbindkeysrc

# Mute/lower/raise volume                                                
"paVolume -m"                                                                      
XF86AudioMute                                                                      
"paVolume -d"                                                                      
XF86AudioLowerVolume                                                               
"paVolume -u"                                                                      
XF86AudioRaiseVolume

Add command xbindkeys to ~/.xinitrc to load the new configuration at startx

if [ -f ~/.xbindkeysrc ]; then
    xbindkeys
fi

2. TrackPoint

Customize pointer settings by installing xinput

sudo apt install xinput

Discover the DEVICE <ID> with xinput list | grep "TrackPoint" | grep "pointer"

xinput list | grep "TrackPoint" | grep "pointer"
 ⎜   ↳ Lite-On Technology Corp. ThinkPad USB Keyboard with TrackPoint    id=13   [slave  pointer  (2)]

Trackpoint is auto-detected but slow. My old method of configuring the pointer was failing under Debian stable/stretch (device id=13) …

xinput set-prop 13 "Device Accel Constant Deceleration" 0.30
    property 'Device Accel Constant Deceleration' doesn't exist, you need to specify its type and format

… and viewing the device properties with xinput list-props 13 shows the problem; the old Device... settings have been replaced with libinput..., which is a library to handle input devices. Xorg in the latest Debian has switched away from using evdev to the libinput driver …

dpkg -l | grep xserver-xorg-input
    [...]
    ii  xserver-xorg-input-libinput     0.23.0-2    amd64   X.Org X server -- libinput input driver

Check out which devices are managed by libinput

grep libinput $HOME/.local/share/xorg/Xorg.0.log

[ Fix! ] Modify the “Coordinate Transformation Matrix”, a transformation matrix used to calculate a pointer movement.

Current setting …

xinput list-props 13 | grep "Coordinate Transformation Matrix"
	Coordinate Transformation Matrix (140): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000

Experiment a bit with setting a new matrix in row-order. 1 I wanted a faster pointer speed and found this configuration to my liking …

xinput set-prop 13 "Coordinate Transformation Matrix" 2.600000, 0.000000, 0.000000, 0.000000, 2.600000, 0.000000, 0.000000, 0.000000, 1.000000

I created a shell script that detects and applies custom settings as per keyboard type. I add the command to my xinitrc to be run at startx

~/bin/keyboardconf & 

Sources: .xmodmap.thinkpad_usb, .xinitrc, .xbindkeysrc.thinkpad_usb, and keyboardconf

Happy hacking!

Notes