
我想使用外部數字鍵盤作為“巨集鍵盤”,每個按鍵都能夠執行指定的操作。我已經創建了一個自訂xkb_keymap
來將鍵映射到XF86
符號。
$ cat ~/.xinitrc
...
# Active macro keyboard
macrokb=$( xinput list | sed -n 's|.*MOSART.*2\.4G.*id=\([0-9]*\).*keyboard.*|\1|p' | head -n1 )
if [ "$macrokb" ]; then
cat ~/.xkb/macros.xkb | xkbcomp -i $macrokb - $DISPLAY
fi
$ cat ~/.xkb/macros.xkb
xkb_keymap "macros" {
xkb_keycodes {
// 0 - Chrome
<WEB> = 90;
// / - Windows
<WIN> = 106;
// * - Win attach
<ATCH> = 63;
// BS - Win detach
<DTCH> = 22;
// enter - Terminal
<TERM> = 104;
// numlock - Settings
<SETT> = 77;
};
xkb_types {
include "basic"
include "numpad"
};
xkb_compat { include "basic" };
xkb_symbols {
key.type = "ONE_LEVEL";
key <WEB> { [ XF86WWW ] };
key <WIN> { [ XF86Launch0 ] };
key <ATCH> { [ XF86Launch1 ] };
key <DTCH> { [ XF86Launch2 ] };
key <TERM> { [ XF86Terminal ] };
key <SETT> { [ XF86Tools ] };
};
};
自訂鍵盤映射已成功載入並偵測到xev
。例子:
KeyPress event, serial 41, synthetic NO, window 0x5800001,
root 0x4f7, subw 0x0, time 5314499, (1656,414), root:(1656,443),
state 0x10, keycode 106 (keysym 0x1008ff40, XF86Launch0), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
現在有問題的部分來了:當我在 KDE 中創建自訂鍵盤快捷鍵時,它成功識別了 例如XF86 keysym
或WWW
但Terminal
我提供的腳本未執行(因此 KDE 未檢測到該快捷鍵)。
然而,對於其他一些按鍵(內建在我的主鍵盤中),例如,情況並非如此XF86AudioPlay
。
我該如何解決這個問題?