我正在尝试更多地利用我的功能键。我希望物理F1键F12显示为F21
,F32
这样我就可以在窗口管理器中将功能分配给F21
等(例如,每当我按 时切换到活动聊天窗口F22
。)
但是我仍然想访问正常的功能键,因此我希望能够按住物理Caps Lock键并按下F1以生成F1
按键。就其他修饰符而言,如果它们保持不变就好了,所以Shift+F1产生Shift + F1
(not Shift + F21
)。总之:
- F1->
F21
- Caps+ F1->
F1
- Shift+ F1->
Shift + F1
(不变) - Alt+ F1->
Alt + F1
(不变) - ETC。
因此,只有前两个点需要更改默认布局。
我尝试使用以下 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> };
};
当我尝试加载它时,我收到此警告:
Warning: Type "HYPER" has 3 levels, but <FK01> has 5 symbols
Ignoring extra symbols
我真的不明白为什么会收到错误,因为虽然默认<FK01>
有五个级别,但我重新定义的只有三个。
当我测试此配置时,果然我F21
在按下物理F1键时得到了,并且在按下时得到了Hyper_L
(和Mod3
)设置Caps Lock。但是按Caps Lock+F1会产生Mod3 + F21
而不是F1
.
答案1
与往常一样,在发布问题后不久就解决了这个问题。问题很简单,我正在使用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> };
};
同样,这会:
- F1->
F21
- Caps+ F1->
F1
- Shift+ F1->
Shift + F1
(不变) - Alt+ F1->
Alt + F1
(不变) - 等等-所有其他不变