Xkb
使用 xcape 和 xkb 將普通鍵作為修飾符
為了在適當的情況下
Spacebar
行事Ctrl
,目前的 GitHub 頁面xcape
說明如下:# Map an unused modifier's keysym to the spacebar's keycode and make it a # control modifier. It needs to be an existing key so that emacs won't # spazz out when you press it. Hyper_L is a good candidate. spare_modifier="Hyper_L" xmodmap -e "keycode 65 = $spare_modifier" xmodmap -e "remove mod4 = $spare_modifier" # hyper_l is mod4 by default xmodmap -e "add Control = $spare_modifier" # Map space to an unused keycode (to keep it around for xcape to # use). xmodmap -e "keycode any = space" # Finally use xcape to cause the space bar to generate a space when tapped. xcape -e "$spare_modifier=space"
如何用
xkb
而不是實現這一點xmodmap
?
Hyper_R
代替,它Hyper_L
是這樣的:內容
~/.config/xkb/keycodes/my-keycodes
:xkb_keycodes "xcape-special" { <HYPR> = 65; <SPCE> = 207; };
注意:是我機器上傳入的鍵碼表中
207
(虛擬)鍵的預設鍵碼。Hyper_R
內容
~/.config/xkb/symbols/my-symbols
:xkb_symbols "xcape-special" { key <HYPR> { [ Hyper_R ] }; modifier_map Control { <HYPR> }; };
摘自
~/.xinitrc
:XKB_DIR="$HOME/.config/xkb" XKB_SYMBOL_FILE="my-symbols" XKB_KEYCODE_FILE="my-keycodes" setxkbmap -layout "us+$XKB_SYMBOL_FILE(xcape-special)" \ -keycodes "evdev+$XKB_KEYCODE_FILE(xcape-special)" \ -option "" -print \ | xkbcomp -I"$XKB_DIR" - "${DISPLAY%%.*}" >/dev/null 2>&1 xcape -e "Hyper_R=space"
這不是配置的唯一方法
xkb
。配置可能通過單個xkbcomp
呼叫從單個文件載入。的子目錄~/.config/xkb/
僅遵循/usr/share/X11/xkb/
. 該... -print | xkbcomp ...
部分有些複雜但靈活。目前我無法嘗試更簡單的設置。