![自定义键盘布局的行为与上次选择的相同](https://linux22.com/image/1146578/%E8%87%AA%E5%AE%9A%E4%B9%89%E9%94%AE%E7%9B%98%E5%B8%83%E5%B1%80%E7%9A%84%E8%A1%8C%E4%B8%BA%E4%B8%8E%E4%B8%8A%E6%AC%A1%E9%80%89%E6%8B%A9%E7%9A%84%E7%9B%B8%E5%90%8C.png)
我正在尝试按照 Stack Exchange 答案和其他教程中给出的说明在 XKB 中创建自定义布局。我在文件中有以下内容my
:
default alphanumeric_keys
xkb_symbols "basic" {
name[Group1]="MyLayout";
key <AC01> { [ UE700 ] };
key <AC02> { [ UE701 ] };
key <AC03> { [ UE702 ] };
key <AC04> { [ UE703 ] };
key <AC05> { [ UE704 ] };
key <AC06> { [ UE705 ] };
key <AC07> { [ UE706 ] };
key <AC08> { [ UE707 ] };
key <AC09> { [ UE708 ] };
key <AC10> { [ UE709 ] };
key <AC11> { [ UE70A ] };
key <AD03> { [ UE70B ] };
};
我在evdev.lst
和evdev.xml
文件中添加了块:
// evdev.lst
! layout
my MyLayout
us English (US)
// evdev.xml
<layout>
<configItem>
<name>my</name>
<shortDescription>my</shortDescription>
<description>MyLayout</description>
<languageList>
<iso639Id>myl</iso639Id>
</languageList>
</configItem>
<variantList/>
</layout>
我sudo dpkg-reconfigure xkb-data
在测试之前就运行过。布局在我的系统设置中可见,MyLayout
我可以毫无问题地添加它。但是,当我选择它作为活动布局时,它的符号是深灰色的,它的行为与下拉列表中紧接在它之前的布局相同。如果我的列表中有English (US)
, Hebrew
, MyLayout
,我的自定义布局将表现得与希伯来语布局完全一样。如果我删除希伯来语,它将表现得与英语(美国)完全一样。我对此没有什么想法,也没有发现我的语法有问题。
locale is C
Warning! Multiple definitions of keyboard layout
Using command line, ignoring X server
Trying to load rules file ./rules/evdev...
Trying to load rules file /usr/share/X11/xkb/rules/evdev...
Success.
Applied rules from evdev:
rules: evdev
model: pc105
layout: my
variant: basic
options: compose:ralt,lv3:caps_switch
Trying to build keymap using the following components:
keycodes: evdev+aliases(qwerty)
types: complete
compat: complete
symbols: pc+my(basic)+inet(evdev)+compose(ralt)+level3(caps_switch)
geometry: pc(pc105)
xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwerty)" };
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols { include "pc+my(basic)+inet(evdev)+compose(ralt)+level3(caps_switch)" };
xkb_geometry { include "pc(pc105)" };
};
答案1
您需要在其中添加实际规则/usr/share/X11/xkb/rules/evdev
;evdev.{lst,xml}
文件仅是描述。
我最好的猜测是您需要类似以下内容:
# existing lines
! model layout variant = symbols
* ben basic = pc+in(ben)
# your additions
* my basic = pc+my(basic)
我假设您的my
文件是/usr/share/X11/xkb/symbols/my
。前 3 列匹配 XKB 输入参数(此处为任何-model
、-layout my
、-variant basic
)。最后一列根据要加载的符号文件定义符号规则,格式为file(clause)
(多个文件以 分隔+
)。符号文件全部为/usr/share/X11/xkb/symbols
。
尝试一下——你可以用类似这样的方法进行测试以确保它正常工作(请注意+my(basic)
以下xkb_symbols
行):
$ setxkbmap -layout my -variant basic -print
xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwerty)" };
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols { include "pc+my(basic)+inet(evdev)" };
xkb_geometry { include "pc(pc105)" };
};
一个问题是,我不确定您的my
定义是否与现有布局冲突。如果这是一个全新的布局,您可能应该将其命名为其他名称以避免冲突。