I did a fresh installation of jammy 22.04. In my previous Ubuntu version, I'd remapped Caps lock to Esc when pressed and released, and to control when held in combination with other keys. It's good for vim, of course. I can't get it working in 22.04, maybe because of the switch to Wayland. The solutions I've found from Googling haven't worked, maybe because they were for earlier versions of Ubuntu.
I added XKBOPTIONS="ctrl:nocaps"
to /etc/default/keyboard
, but it didn't work. I also tried caps2esc and xcape but haven't had success since I don't entirely know what I'm doing. I'd like to do this mapping with my dot files, not by downloading a package or adding a repository unless it's really much more convenient to do that. Can someone provide me with some code I can put into my dotfiles in jammy 22.04 so that the Caps lock key gets mapped to Escape when pressed and released, and mapped to Control when held down in combination with other keys? Thanks for any help here.