交換ctrl和caps_loack的新方法
Table of Contents
1 過程
debian用了幾年,因爲emacs的關係,一直將右ctrl和caps_lock鍵交換,使用的是xmodmap 方式,寫了.Xmodmap腳本,在.xinitrc中加入:xmodmap ~/.Xmodmap,但最近這個方法無效 了,我只能在.bashrc中執行腳本,可是每開一次終端,腳本都會執行一次,因此再次打開 終端,鍵位就恢復了。bash
! ! Swap Caps_Rock and Control_R ! remove Lock = Caps_Rock remove Control = Control_R keysym Control_R = Caps_Rock keysym Caps_Rock = Control_R add Lock = Caps_Rock add Control = Control_R
我將腳本執行放在.xsession,.xsessionrc中都在沒法開機時自動執行xmodmap, 最後只有求助於setxkbmap。setxkbmap選項位於這幾個文件裏: /usr/share/X11/xkb/rules/evdev.lst /usr/share/X11/xkb/rules/base.lst,這倆文件一模 同樣……,利用grep搜索過濾"ctrl:或:ctrl"。session
$ grep -e "ctrl:\|:ctrl" /usr/share/X11/xkb/rules/evdev.lst grp:ctrls_toggle Both Ctrl keys together grp:ctrl_shift_toggle Ctrl+Shift grp:ctrl_alt_toggle Alt+Ctrl ctrl:nocaps Caps Lock as Ctrl ctrl:lctrl_meta Left Ctrl as Meta ctrl:swapcaps Swap Ctrl and Caps Lock ctrl:ac_ctrl At left of 'A' ctrl:aa_ctrl At bottom left ctrl:rctrl_ralt Right Ctrl as Right Alt ctrl:menu_rctrl Menu as Right Ctrl ctrl:ctrl_ralt Right Alt as Right Ctrl caps:ctrl_modifier Make Caps Lock an additional Control but keep the Caps_Lock keysym altwin:ctrl_win Control is mapped to Win keys (and the usual Ctrl keys) altwin:ctrl_alt_win Control is mapped to Alt keys, Alt is mapped to Win keys terminate:ctrl_alt_bksp Control + Alt + Backspace
我選擇了ctrl:nocaps,執行dconf-editor, 在org.gnome.desktop.inputsources下面, xkboptions選項,添加以下:['ctrl:nocaps'],OK.若需當即生效,終端鍵入 setxkbmap -print便可。app