Mal*_*ous 5 xorg xkb keyboard-layout
我正在尝试更多地利用我的功能键。我想物理F1到F12键显示为F21
对F32
,所以我可以分配功能来F21
在我的窗口管理器等(如开关,每当我按活动聊天窗口F22
。)
但是我仍然想要访问普通功能键,所以我希望能够按住物理Caps Lock键并按下F1以生成F1
按键。就其他修饰符而言,如果它们保持不变就好了,所以Shift+F1产生Shift + F1
(not Shift + F21
)。总之:
F21
F1
Shift + F1
(不变)Alt + F1
(不变)所以只有前两个点需要更改默认布局。
我尝试使用以下 XKB 片段开始此操作,虽然它生成F21
for F1,但在按住时不会生成原始 F 键Caps Lock:
partial
xkb_types "hyper" {
virtual_modifiers Alt,Hyper;
type "HYPER" {
modifiers= Hyper+Control+Alt;
map[Hyper]= Level2;
map[Control+Alt]= Level3;
level_name[Level1]= "Extra";
level_name[Level2]= "Normal";
level_name[Level3]= "Normal+Ctrl+Alt";
};
};
partial function_keys
xkb_symbols "hyper_f21" {
replace key <FK01> {
type= "HYPER",
symbols[Group1]= [ F21, F1, XF86Switch_VT_1 ]
};
replace key <FK02> {
type= "HYPER",
symbols[Group1]= [ F22, F2, XF86Switch_VT_2 ]
};
...
};
partial modifier_keys
xkb_symbols "caps_hyper" {
replace key <CAPS> {
[ Hyper_L, Hyper_L ]
};
modifier_map Lock { <KPDL> }; # Not sure how to clear modifiers, so assign an unused key
modifier_map Mod3 { <CAPS> };
};
Run Code Online (Sandbox Code Playgroud)
当我尝试加载它时,我收到此警告:
Warning: Type "HYPER" has 3 levels, but <FK01> has 5 symbols
Ignoring extra symbols
Run Code Online (Sandbox Code Playgroud)
我真的不明白为什么我会收到错误,因为虽然默认<FK01>
有五个级别,但我重新定义的只有三个。
当我测试这个配置时,我确实F21
在按下物理F1键时得到了,并且在按下时得到了Hyper_L
(和Mod3
)设置Caps Lock。但是按Caps Lock+F1会产生Mod3 + F21
而不是F1
.
与往常一样,在发布问题后不久就弄清楚了这一点。问题很简单,我使用的Hyper_L
是默认情况下分配给Mod4
. 通过Caps Lock改为Hyper_R
改为,它起作用了。它仍然必须绑定,Mod3
因为仍然需要一个真正的修饰符。
这是现在产生所需行为的更新配置:
partial
xkb_types "hyper" {
virtual_modifiers Alt,Hyper;
type "HYPER" {
modifiers= Shift+Control+Alt+Hyper;
map[Shift]= Level2;
preserve[Shift]= Shift;
map[Control]= Level2;
preserve[Control]= Control;
map[Shift+Control]= Level2;
preserve[Shift+Control]= Shift+Control;
map[Alt]= Level2;
preserve[Alt]= Alt;
map[Shift+Alt]= Level2;
preserve[Shift+Alt]= Shift+Alt;
map[Control+Alt]= Level3;
preserve[Control+Alt]= Control+Alt;
map[Shift+Control+Alt]= Level2;
preserve[Shift+Control+Alt]= Shift+Alt;
map[Hyper]= Level2;
level_name[Level1]= "Extra";
level_name[Level2]= "Normal";
level_name[Level3]= "Ctrl+Alt";
};
};
partial function_keys
xkb_symbols "hyper_f21" {
replace key <FK01> {
type= "HYPER",
symbols[Group1]= [ F21, F1, XF86Switch_VT_1 ]
};
replace key <FK02> {
type= "HYPER",
symbols[Group1]= [ F22, F2, XF86Switch_VT_2 ]
};
...
};
partial modifier_keys
xkb_symbols "caps_hyper" {
replace key <CAPS> {
[ Hyper_R ]
};
# Remove Hyper (Hyper_L/Hyper_R) from Mod4, was added by "pc" layout
modifier_map none { <HYPR> };
# Now make physical caps lock (mapped to Hyper_R above) control Mod3. Mod3 is
# associated with the virtual modifier "Hyper" because the existing XKB config
# links Hyper_L and Hyper_R with this virtual modifier. Therefore Mod3 becomes
# the virtual modifier "Hyper" because they both share the same keysym Hyper_R.
modifier_map Mod3 { <CAPS> };
};
Run Code Online (Sandbox Code Playgroud)
同样,这样做:
F21
F1
Shift + F1
(不变)Alt + F1
(不变)