Keyboard Remapping in Linux
Keyboard Remapping in Linux
I was given a 60% keyboard for Christmas two years ago that I never used because of the layout. Some important keys were moved and I couldn’t type on it well. I created a script to remap the keys for me. The code and installer for this can be found here.
Xmodmap
Xmodmap is the program I use to remap keys using some commands in bash. For my keyboard I need to map RSHIFT to ‘/’ and CAPSLOCK to ‘`’. The following commands are what I use to remap.
xmodmap -e "keycode 62 = slash question"
xmodmap -e "clear lock"
xmodmap -e "keycode 66 = grave asciitilde"
Searching for Keyboards
To search for my keyboard I use lsusb and grep for the keyboard name.
lsusb | grep -q "$KEYBOARD_NAME"
Installation Using Make
In my repository running make install
will put the script in /etc/profile.d
.
# remap SINO WEALTH keyboard
SPECIAL_KEYBOARD="SINO WEALTH Mechanical Keyboard"
lsusb | grep -q "${SPECIAL_KEYBOARD}"
if [ $? -eq 0 ]; then
xmodmap -e "keycode 62 = slash question"
xmodmap -e "clear lock"
xmodmap -e "keycode 66 = grave asciitilde"
fi
More Documentation
Some more docs on this can be found here.