0

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

1
+50

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$"
/usr/share/kbd/keymaps/i386/include/azerty-layout.inc
/usr/share/kbd/keymaps/i386/include/compose.inc
/usr/share/kbd/keymaps/i386/include/euro1.inc
/usr/share/kbd/keymaps/i386/include/linux-keys-bare.inc
/usr/share/kbd/keymaps/i386/include/linux-keys-extd.inc
/usr/share/kbd/keymaps/i386/include/linux-with-alt-and-altgr.inc
/usr/share/kbd/keymaps/i386/include/linux-with-modeshift-altgr.inc
/usr/share/kbd/keymaps/i386/include/linux-with-two-alt-keys.inc
/usr/share/kbd/keymaps/i386/include/qwerty-layout.inc
/usr/share/kbd/keymaps/i386/include/qwertz-layout.inc
/usr/share/kbd/keymaps/mac/include/apple-a1048-base.inc
/usr/share/kbd/keymaps/mac/include/apple-a1243-fn-reverse.inc
/usr/share/kbd/keymaps/mac/include/apple-a1243-fn.inc
/usr/share/kbd/keymaps/mac/include/mac-azerty-layout.inc
/usr/share/kbd/keymaps/mac/include/mac-linux-keys-bare.inc
/usr/share/kbd/keymaps/mac/include/mac-qwerty-layout.inc
/usr/share/kbd/keymaps/mac/include/mac-qwertz-layout.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[] = {
    "",
    NULL
};
static const char *const include_dirpath1[] = {
    "",
    "../include/",
    "../../include/",
    NULL
};
static const char *const include_dirpath3[] = {
    DATADIR "/" KEYMAPDIR "/include/",
    DATADIR "/" KEYMAPDIR "/i386/include/",
    DATADIR "/" KEYMAPDIR "/mac/include/",
    NULL
};

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

static const char *const include_suffixes[] = {
    "",
    ".inc",
    NULL
};

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
3
  • Thanks for your effort, this helped a lot! :)
    – maddingl
    Jan 20, 2021 at 13:43
  • 1
    Does it work for you? Jan 20, 2021 at 13:44
  • yes, it works :)
    – maddingl
    Jan 20, 2021 at 13:45

You must log in to answer this question.

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