Permanent xmodmap in Ubuntu 13.04
Ubuntu no longer uses xmodmap
, but instead uses xkb
(as far as I understand, this facilitates per-window keyboard layouts, among other things).
The system-wide map files are in
/usr/share/X11/xkb/symbols/
The maps appears to be loaded hierarchically, with the pc
map as the root, and whatever language (e.g. en
) as a child of the root.
In my particular case, I physically swapped Page Up with Home and Page Down with End on my keyboard, so I very crudely made changes to the system-wide pc
map, as follows:
key <HOME> { [ Prior ] };
key <PGUP> { [ Home ] };
key <END> { [ Next ] };
key <PGDN> { [ End ] };
NOTE: To force Xorg to use your new keyboard map, you may have to remove the existing pre-compiled maps (*.xkm) in
/var/lib/xkb/
and then restart Xorg.
There are various resources on xkb
, but this one is related to Ubuntu.
For me, the xkb configuration is too complicated if you want to remap 1 or 2 keys in a way not available in the System Settings. Plus, the solution should remain on the user side, without editing '/usr/share/X11/xkb/symbols/' etc. Force the 'xmodmap ~/.Xmodmap' load using the Startup Applications only works until you suspend, change users or change the keyboard layout. So, as holocronweaver suggests, with code snippets I found, I made a python script to be loaded on session startup, that reloads the '~/.Xmodmap' when needed.
Check the bug report #1243642 (comment #6), and download it here.
I had this problem in Ubuntu 14.04, and found the solution here. Apparently, Ubuntu is not able to configure the keyboard right away after logging in, but it is a bit later. So if you add a command
sleep 4 && xmodmap ~/.Xmodmap &
to ~/.bash_profile
then it should work (it does for me).
EDIT: This seems to work only after logging in, not after starting up. I'll have to investigate this later.