使用过 .xmodmap,重启后就失效,添加到rc.local也不管用,后来通过在xorg里配置成功。
更改xorg里的键盘配置,增加Option "XkbOptions" "caps:swapescape"
我用的archlinux在/etc/X11/xorg.conf.d/00-keyboard.conf,有些可能在 /etc/X11/xorg.conf
一个可能的键盘字段类似下面这样
Section "InputClass"
Identifier "system-keyboard"
MatchIsKeyboard "on"
Option "XkbOptions" "caps:swapescape"
Option "XkbLayout" "cn"
Option "XkbModel" "pc105"
EndSection
类似的命令可以在/usr/share/X11/xkb/rules/xorg.lst里找到,比如
caps:internal Caps Lock uses internal capitalization; Shift "pauses" Caps Lock
caps:internal_nocancel Caps Lock uses internal capitalization; Shift does not affect Caps Lock
caps:shift Caps Lock acts as Shift with locking; Shift "pauses" Caps Lock
caps:shift_nocancel Caps Lock acts as Shift with locking; Shift does not affect Caps Lock
caps:capslock Caps Lock toggles normal capitalization of alphabetic characters
caps:shiftlock Caps Lock toggles ShiftLock (affects all keys)
caps:swapescape Swap ESC and Caps Lock
caps:escape Make Caps Lock an additional Esc
caps:backspace Make Caps Lock an additional Backspace
caps:super Make Caps Lock an additional Super
caps:hyper Make Caps Lock an additional Hyper
caps:menu Make Caps Lock an additional Menu key
caps:numlock Make Caps Lock an additional Num Lock
标签:additional,Lock,Make,caps,Shift,Esc,Linux,Caps
来源: https://www.cnblogs.com/lepeCoder/p/swap_ESC_and_Caps.html