Today a small tutorial on how to remap keys under linux

We need two tools xev and xmodmap.

First, we wonder what keys we want to remap. The following example will show you switching places PgUp <=> Home and PgDwn <=> End so lets play.

Execute:

# xev | grep KeyRelease -A2

and then push one by one: PgUp, Home, PgDwn, End

KeyRelease event, serial 40, synthetic NO, window 0x6a00001,
root 0xc5, subw 0x0, time 5241246, (556,-209), root:(556,479),
state 0x10, keycode 112 (keysym 0xff55, Prior), same_screen YES,
KeyRelease event, serial 40, synthetic NO, window 0x6a00001,
root 0xc5, subw 0x0, time 5241816, (556,-209), root:(556,479),
state 0x10, keycode 110 (keysym 0xff50, Home), same_screen YES,
KeyRelease event, serial 40, synthetic NO, window 0x6a00001,
root 0xc5, subw 0x0, time 5242857, (556,-209), root:(556,479), state 0x10, keycode 117 (keysym 0xff56, Next), same_screen YES, KeyRelease event, serial 40, synthetic NO, window 0x6a00001,
root 0xc5, subw 0x0, time 5243418, (556,-209), root:(556,479), state 0x10, keycode 115 (keysym 0xff57, End), same_screen YES,

for the above, we calculate the hexadecimal values of the selected codes:

PgUp  => keycode 112 => 0x70
Home  => keycode 110 => 0x6e
PgDwn => keycode 117 => 0x75
End   => keycode 115 => 0x73

not You have to create file ~/.xmodmap with command:

touch ~/.xmodmap

and now write inside modified codes:

keycode 0x70 = Home NoSymbol NoSymbol NoSymbol
keycode 0x6E = Prior NoSymbol NoSymbol NoSymbol
keycode 0x75 = End NoSymbol NoSymbol NoSymbol
keycode 0x73 = Next NoSymbol NoSymbol NoSymbol

To apply the above settings we run from the command line:  xmodmap ~/.xmodmap

 

If we want the above to be always loaded at login, we edit or create if there is no file ~/.xinitrc

#!/bin/sh
# Custom keyboard mapping
xmodmap ~/.xmodmap

Comments


Comments are closed