交换ctrl和caps_loack的新方法
Table of Contents
1 过程
debian用了几年,由于emacs的关系,一直将右ctrl和caps_lock键交换,使用的是xmodmap 方式,写了.Xmodmap脚本,在.xinitrc中加入:xmodmap ~/.Xmodmap,但最近这个方法无效 了,我只能在.bashrc中执行脚本,但是没开一次终端,脚本都会执行一次,所以再次打开 终端,键位就恢复了。
! ! 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"。
$ 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即可。