Posts Tagged ‘Ubuntu

28
Sep
08

Remapping keyboard keys on X

I’ll share this tip since it took me some time to figure out this fix. I guess it is quite common in notebook keyboard to have such unusual layouts as mine (below):

The first impression I had when I bought this notebook was: “I guess slashes and question marks aren’t here on normal abnt2 keyboards…” but… Windows came bundled in my laptop and it was already remapped.

Then I installed Ubuntu (I guess it was 7.10 by the time) and for my surprise… the key seemed dead until I figured out that Right Control was missing… in fact my slash/question mark key was the right control. So I started a long research to find out how to fix this and after some research I discovered for both X and console. The solution is:

  • For X

Create a file under /usr/share/X11/xkb/symbols. I’ve named mine lenovo (guess why) and place this inside it:

partial modifier_keys
xkb_symbols "addslashes" {
key <RCTL> {  [ slash, question, degree ] };
};

Then modify your /etc/X11/xorg.conf and change XkbLayout section to this:


    Option        "XkbLayout"    "br+lenovo(addslashes)"

With this you override only this key from the original br keymap.

In order to find out the original key, in case you have a similar problem, run xev and have a look on the output. Mine looked like this (Control_R code confirms what I guessed, the key was in fact a Right control key):


KeyPress event, serial 34, synthetic NO, window 0x4a00001,
root 0x7a, subw 0x0, time 3139474, (430,712), root:(437,763),
state 0x0, keycode 105 (keysym 0xffe4, Control_R), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False

  • For Console keys

In order to change console keys you need to change the following file: /etc/console-tools/remap

and place the key changes there. It works like a file replace. So in order to make the same change I’d have this content inside it.


s/keycode  97 = Control/keycode  97 = slash/
/keycode  97 = slash/ashift keycode  97 = question
/keycode  97 = question/aaltgr keycode  97 = degree

For some weird reason, Ubuntu 7.10 and 8.04 wasn’t executing console remapping.

And at last, unfortunately this tip does not work anymore on upcoming Ubuntu 8.10 since it changed its key map control to use hal and evdev. So, I am back to where I was last year. If anyone by accident know how to do this in recent distros, please post a comment.

Advertisements



ClustrMaps

Blog Stats

  • 361,304 hits since aug'08

%d bloggers like this: