Dot xmodmap

The xmodmap utility is useful for remapping keys. I use it to change the behaviour of a few keys on chromebook keyboards.

Let's go!

Install (on Debian) x11-xserver-utils and write any modifications to a newly-created ~/.xmodmap ...

$ sudo apt install x11-xserver-utils
$ touch ~/.xmodmap

View the current keymap and I note the keycodes to be remapped ...

$ xmodmap -pke
keycode 108 = Alt_R Meta_R Alt_R Meta_R
keycode 124 = XF86PowerOff NoSymbol XF86PowerOff
keycode 133 = Super_L NoSymbol Super_L

Make my changes in ~/.xmodmap ...

! Chromebook 'Search' meta key to backspace
! IMPORTANT: 'clear Mod4' to enable key combo in GTK apps
clear Mod4
keycode 133 = BackSpace

keycode 108 = Alt_R

! 'HandlePowerKey=ignore' in /etc/systemd/logind.conf and powerkey to pause
keycode 124 = Pause

Run xmodmap ~/.xmodmap to activate the key remapping. Check out the altered keycodes ...

$ xmodmap -pke
keycode 108 = Alt_R NoSymbol Alt_R
keycode 124 = Pause NoSymbol Pause
keycode 133 = BackSpace NoSymbol BackSpace

Make an entry in ~/.xinitrc to run the command at startx ...

$ xmodmap -pke

# Modify key mappings (handled by keyboardconf)
if [ -f ~/.xmodmap ]; then
    xmodmap ~/.xmodmap

Sources: dotfiles/.xmodmap.chromebook and dotfiles/.xinitrc

Happy hacking!

More • dotfilesshelllinuxkeyboard