top image
home  /  pages  /  tech tips  /  contact about

Make kxkb, xmodmap, and xkb work together

Problem

Whenever you switch layouts with kxkb, your xmodmap settings disappear and you cannot get them back. (For example, when trying to disable Caps Lock or mapping Caps Lock to some other key.)

Keywords

kxkb, xmodmap, xkb, keyboard, layout

Solution

Sadly, in contrast to my many other howtos, there is no solution to this problem. The only "solution" is to forget about xmodmap and drink the xkb coolaid: define your own xkb map and convince kxkb to use it.

I edited /etc/X11/xkb/symbols/us (because my change is a variation on a us keyboard layout) and added:

partial alphanumeric_keys
xkb_symbols "thomer" {
    include "us"
    name[Group1]= "U.S. English - Thomer";
    key <CAPS> {  [ Escape ] };
};

Restart X.

Configure kxkb to use layout variant "thomer" (or whatever you named yours) when using the us keymap.

In this particular change, Caps Lock now works like Escape—for all you vi lovers out there.

In the good old xmodmap world, you would have been able to achieve this using:

xmodmap -e 'clear Lock'
xmodmap -e 'keycode 66 = Escape'
URL: https://thomer.com/howtos/kxkb_xmodmap.html
Copyright © 1994-2022 by Thomer M. Gil
Updated: 2007/08/18