I currently have Caps Lock mapped to Ctrl when held and Esc when tapped (for vim) via these commands in .xinitrcsetxkbmap -option 'caps:ctrl_modifier'xcape -e 'Caps_Lock=Escape'This works, but leaves me without Caps Lock so I want to remap Esc to Caps Lock.I've tried setting it with xmodmap -e 'keycode 9 = Caps_Lock' but that overrides the mapping on the Caps Lock key as well.Is there any way to achieve these mappings?Caps Lock -> Ctrl and EscEsc -> Caps Lock
Remap Esc to Caps Lock after mapping Caps Lock to Ctrl and Esc with xcape
keyboard layout;capslock;xcape
You can use setxkbmap or xmodmap to swap Caps Lock and Escape.  With xmodmap you could have:! Remove Caps_Lock modifier from real Caps Lock keyclear Lock! Set real Caps Lock key to present as (left) controlkeycode 66 = Control_L! Set real Escape key to present as Caps Lockkeycode 9 = Caps_Lock! Make a fake key to hold the Escape keysym, so xcape can use itkeycode 255 = Escape! Make Caps_Lock and Control_L work as one would expectadd Lock = Caps_Lockadd Control = Control_L(The lines starting with ! are comments.)Put this in ~/.xmodmaprc and run xmodmap ~/.xmodmaprc,then run xcape -e '#66=Escape' to add Escape functionality to the real Caps Lock key.