9

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).

muru
  • 193,181
  • 53
  • 473
  • 722
Magnus Teekivi
  • 245
  • 1
  • 2
  • 6

1 Answers1

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

Rmano
  • 31,627
  • 16
  • 118
  • 187
  • 1
    It would be great to add that the modern analog [to xmodmap is xkb](http://ebb.org/bkuhn/blog/2011/05/31/x.html). I didn't know it. – Hi-Angel Oct 02 '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: http://www.charvolant.org/~doug/xkb/html/xkb.html – Rmano Oct 02 '15 at 17:05
  • 1
    In the end, I find easier to [define my own keyboard](http://rlog.rgtti.com/2014/05/01/how-to-modify-a-keyboard-layout-in-linux/) – Rmano Oct 02 '15 at 17:12
  • 1
    Thanks. I found the option in System Settings -> Keyboard -> Options. Should have done proper research. – Magnus Teekivi Oct 02 '15 at 17:44