Remapping Caps Lock with xmodmap doesn't work
The xmodmap(1) man page has an example for exactly this
!
! Swap Caps_Lock and Control_L
!
remove Lock = Caps_Lock
remove Control = Control_L
keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L
add Lock = Caps_Lock
add Control = Control_L
but if you want to finish doing it the way you started, I think you need to add at least the remove
and add
lines
remove Lock = Caps_Lock
remove Control = Control_L
keycode 37 = Caps_Lock
keycode 66 = Control_L
add Lock = Caps_Lock
add Control = Control_L
I'm guessing that's the case based on this paragraph
add MODIFIERNAME = KEYSYMNAME ...
This adds all keys containing the given keysyms to the indi‐
cated modifier map. The keysym names are evaluated after all
input expressions are read to make it easy to write expressions
to swap keys (see the EXAMPLES section).
which makes it sound like modifier changes (shift, control, etc.) don't get applied until you run that too.
(And logically the same with remove
)
The keycode
version has the advantage of being idempotent, meaning that the effect won't change if xmodmap is run multiple times.
Loosely related answer: I wanted to remap the caps lock key to left control, leaving the actual left control untouched. The xmodmap man page also offers the solution:
keycode 66 = Control_L
clear Lock
add Control = Control_L