![自定义控制台键盘映射 - 无法打开包含文件](https://linux22.com/image/186554/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%8E%A7%E5%88%B6%E5%8F%B0%E9%94%AE%E7%9B%98%E6%98%A0%E5%B0%84%20-%20%E6%97%A0%E6%B3%95%E6%89%93%E5%BC%80%E5%8C%85%E5%90%AB%E6%96%87%E4%BB%B6.png)
我想按照描述制作自定义控制台键盘映射在 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