I've created a custom keyboard layout, ~/dot/c98.xkb. It looks like this:

// vim: ft=xkb
xkb_keymap {
    xkb_keycodes "k" { include "evdev(evdev)" };
    xkb_geometry "g" { include "pc(pc105)" };

    xkb_types "t" {
    xkb_compat "c" {
    xkb_symbols "s" {

Obviously, there is actually stuff in the empty blocks, but I skipped it to save space.

Compiling and decompiling it through xkbcomp c98.xkb c98.xkm; xkbcomp c98.xkm c98_xkm.xkb creates a file that is equivalent to the original (as similar as any decompiled code is).

However, doing it through xkbcomp c98.xkb $DISPLAY; xkbcomp $DISPLAY c98_display.xkb results in an error message (it still works, though; message copied below), and a file that has some slight resemblance to the original:

  • keycodes includes evdev+aliases(qwerty) instead of just evdev. It's been renamed to evdev+aliases(qwerty).
  • types contains a lot of stuff, but not what I specified (it seems to just include complete), and has been renamed to complete/
  • compat contains what I told it to, but with more virtual_modifiers. That one is also named complete.
  • symbols contains what it should, except the name[group1] field has been changed to English (US), and some of the type fields have weird values - I guess it stores indices and not names, and since the types field is corrupted... This block's name has been changed to pc+us+inet(evdev).
  • geometry seems to contain exactly what it should, including the block name.

It seems like xkbcomp only copies some of the blocks for some reason, leaving the keycodes and types fields alone.

The aforementioned error message when trying to set the layout is:

X Error of failed request:  BadAtom (invalid Atom parameter)
  Major opcode of failed request:  135 (XKEYBOARD)
  Minor opcode of failed request:  18 (XkbSetNames)
  Atom id in failed request:  0x435345
  Serial number of failed request:  70
  Current serial number in output stream:  73

The full source code, as well as a diff between c98_xkm.xkb and c98_display.xkb can be found here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.