Saturday, September 29, 2012

Remapping keys on Ubuntu using xmodmap for DotA

Just thought about playing DotA on Ubuntu using wine. The spell keys were easily set using customkeys generator(http://www.drjones.dk/customkeys/generator.php) but missed autowarkeys for setting key mappings for inventory items. After some surfing found out that xmodmap in ubuntu is the stuff i need.
All i needed for my default mapping of space to num7 and capslock to num8 was the 2 lines:
xmodmap -e "keycode  65 = space KP_7 space space space nobreakspace"
xmodmap -e "keycode  66 = Caps_Lock KP_8 Caps_Lock Caps_Lock Caps_Lock nobreakspace"
and when I am done with it just restore them back using
xmodmap -e "keycode  65 = space space space space space nobreakspace"
xmodmap -e "keycode  66 = Caps_Lock Caps_Lock Caps_Lock Caps_Lock Caps_Lock nobreakspace"

Instead of typing out the long commands every time, it is easier to put the lines in a shell script in ~/bin