8

I am a vim user and I use Esc frequently so I mapped Caps Lock to Esc.

I currently have this in my ~/.profile:

# remap Esc to Caps Lock
xmodmap -e 'clear Lock' -e 'keycode 0x42 = Escape'

The problem is that every time I suspend my computer or even lock the screen, the mapping of Caps Lock goes back to its default.

My question is, where should I put this line so that the remap remains even after suspension and locking the screen (etc).

7

The problem is that xmodmap is deprecated, and the keyboard layout is resetted at strange times. See if https://askubuntu.com/a/464618/16395 can help you.

In gnome-shell you can achieve this thing by setting, in gnome-tweak-tool, one of these options:

gnome tweak tool screenshot editing caps lock behavior

You should be able to find an equivalent thing for Elementary.

See also https://askubuntu.com/a/629043/16395 and Map AltGr-[a..z] and Shift-AltGr-[A..Z] to greek letter

4
  • 1
    It would be great to add that the modern analog to xmodmap is xkb. I didn't know it.
    – Hi-Angel
    Oct 2 '15 at 17:03
  • 2
    @Hi-Angel, I'll add the link. Hower, the problem is still here. On-the-fly use of xkb system is complex and saying that it is sparsely documented is an understatment... read the first quote here: charvolant.org/~doug/xkb/html/xkb.html
    – Rmano
    Oct 2 '15 at 17:05
  • 1
    In the end, I find easier to define my own keyboard
    – Rmano
    Oct 2 '15 at 17:12
  • 1
    Thanks. I found the option in System Settings -> Keyboard -> Options. Should have done proper research. Oct 2 '15 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.