I want to make a custom console keymap as described in the Arch-Wiki

This is my file:

# /usr/local/share/kbd/keymaps/personal.map

include "us"

# swap Caps_Lock and Escape
keycode   1 = Caps_Lock
keycode  58 = Escape

# swap left Alt and Control
keycode  29 = Alt
keycode  56 = Control

# German stuff
keymaps 0-3
keycode 22 = u U udiaeresis Udiaeresis
keycode 24 = o O odiaeresis Odiaeresis
keycode 30 = a A adiaeresis Adiaeresis
keycode 31 = s S ssharp

When I try to load it with loadkeys /usr/local/share/kbd/keymaps/personal.map, I get:

cannot open include file us
syntax error, unexpected ERROR

us is in the result of localectl list-keymaps, of course.

If I replace include "us" with include "linux-with-two-alt-keys" as in the Arch Wiki example, it does work as expected.

Why can I not include the us map?

1 Answer 1


A quick strace loadkeys /usr/local/share/kbd/keymaps/personal.map shows that only include directories and current working directory are searched for files to include and as one can check with locate:

$ sudo updatedb
$ locate -r "keymaps.*\.inc$"

indeed all .inc files reside in a directories named include.

I wasn't able to find an explanation of include mechanism in kbd manpages but it can also be deduced from reading the source code:

static const char *const include_dirpath0[] = {
static const char *const include_dirpath1[] = {
static const char *const include_dirpath3[] = {
    DATADIR "/" KEYMAPDIR "/include/",
    DATADIR "/" KEYMAPDIR "/i386/include/",
    DATADIR "/" KEYMAPDIR "/mac/include/",

You can also see that .inc suffix are added to the included files automatically:

static const char *const include_suffixes[] = {

So, to make loadkeys /usr/local/share/kbd/keymaps/personal.map you need:

zcat /usr/share/kbd/keymaps/i386/qwerty/us.map.gz > /usr/local/share/kbd/keymaps/us.inc
  • Thanks for your effort, this helped a lot! :)
    – maddingl
    Commented Jan 20, 2021 at 13:43
  • 1
    Does it work for you? Commented Jan 20, 2021 at 13:44
  • yes, it works :)
    – maddingl
    Commented Jan 20, 2021 at 13:45
  • You don't need to unzip the keymap, just put .map or .map.gz to the include string. Like so: include "/usr/share/kbd/keymaps/i386/qwerty/us.map.gz", or if us.map.gz is in the same directory as personal keymap: include "us.map". Relative paths like "i386/qwerty/us.map" can also be used. Commented May 5 at 21:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .