Remapping keys in X
Lourens Veen
lourens at rainbowdesert.net
Sat Nov 27 21:38:47 UTC 2004
Hi all,
(Please CC any replies to me, I'm not subscribed, thanks!)
I have an HP Compaq Presario 2535 laptop running Ubuntu 4.10, and it has a
funny keyboard. I have two copies of the \ | key, one to the right of my left
shift key, and one to the bottom left of the return key.
Currently, I have it configured as a standard 104-key keyboard (XkbModel
"pc104", XkbLayout "us") and I'm using a Dvorak keymap (somehow, I just
selected it in the installer, I don't know why the XF86Config-4 file says
"us" for the layout either...). The \ | key next to my return key works as
expected, the one next to my left shift key doesn't give any key at all. It
generates keycodes, but these are never mapped to keysyms.
I'd like to use the key next to the left shift key as \ |, and have the one
next to my return key act as return, so that I get a nice big J-shaped return
key rather than a thin q-shaped one. On my previous Slackware install, I did
this by simply having a ~/.Xmodmap file containing the lines
keysym 94 = backslash bar
keysym 51 = Return
and all was well. If I do this manually from a console (xmodmap -e), it works
on Ubuntu as well.
However, on Ubuntu, automatically loading this from ~/.Xmodmap doesn't seem to
work (that is, my ~/.Xmodmap seems to be ignored, and I once (but only once!)
got a popup when I logged on about there being a ~/.Xmodmap file, and that it
would be ignored). I browsed through the scripts in /etc/X11 for a bit, and
noticed that in /etc/X11/gdm/Xsession, the ~/.Xmodmap only gets loaded when
Xkb is not in use since according to the comment "xkb and xmodmap don't play
nice together". It appears that I should use ~/.Xkbmap instead, but the
little bit of documentation I found on that doesn't say anything about
remapping individual keys. I've tried various things with custom ~/.xinitrc
and ~/.xsession files as well, but it appears that these are never being run.
There is another little twist in that to be totally "correct", fixing the key
next to the left shift to do what its label says (keysym 94 = backslash bar)
should be a systemwide setting (since it's hardware specific), while
remapping the key next to return to be a return too is a personal preference,
so it should be user-specific. However, this is effectively a single-user
machine, so it's not that important.
So to get to the point: what is the standard way of remapping a few individual
keys in X in Ubuntu?
Thanks in advance,
Lourens
More information about the ubuntu-users
mailing list