我想按照描述制作自定义控制台键盘映射在 Arch-Wiki 中
这是我的文件:
# /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
当我尝试使用 加载它时loadkeys /usr/local/share/kbd/keymaps/personal.map
,我得到:
cannot open include file us
syntax error, unexpected ERROR
us
localectl list-keymaps
当然,是在 的结果中。
如果我替换include "us"
为include "linux-with-two-alt-keys"
Arch Wiki 示例中的内容,它确实会按预期工作。
为什么我不能包含us
地图?
答案1
快速strace loadkeys /usr/local/share/kbd/keymaps/personal.map
显示仅include
搜索目录和当前工作目录以查找要包含的文件,并且可以使用以下命令进行检查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
事实上,所有 .inc 文件都驻留在名为 的目录中include
。
我无法在 kbd 联机帮助页中找到包含机制的解释,但也可以通过阅读源代码:
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
};
您还可以看到该.inc
后缀自动添加到包含的文件中:
static const char *const include_suffixes[] = {
"",
".inc",
NULL
};
所以,为了让loadkeys /usr/local/share/kbd/keymaps/personal.map
你需要:
zcat /usr/share/kbd/keymaps/i386/qwerty/us.map.gz > /usr/local/share/kbd/keymaps/us.inc