Arch-Linux
自定義控制台鍵盤映射 - 無法打開包含文件我們
我想製作一個自定義控制台鍵盤映射,如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
地圖?
快速
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 文件都駐留在名為 .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