How to permanently switch Caps Lock and Esc

Another way to do this is through the dconf-editor. This method has a few extra steps from gnome-tweak-tool, but is useful if you don't want to pull in the dependencies from the tweak tool.

This will allow you to use the caps:swapescape syntax and automatically make the change permanent.

sudo apt-get install dconf-tools

After starting the dconf-editor, navigate to org >> gnome >> desktop >> input-sources

Add the options that you need in xkb-options. The option strings are surrounded by single quotes and separated by commas. Be careful not to delete the brackets on the ends.

xkb-options in dconf-editor

You can use this method to enter most of the traditional xkb options that are no longer available in System Settings >> Text Entry. The exception are the settings for switching the keyboard layouts, which currently do not work because of a bug.

For a list of the options and the syntax, use man 7 xkeyboard-config in a terminal.

Another common option that could be used is terminate:ctrl_alt_bksp to allow ctrl+alt+backspace to end the X-session.


A solution that should work for most linux distros:

setxkbmap -option caps:swapescape

Other options are possible:

  • caps:none to deactivate
  • caps:escape to make it an additional escape
  • caps:super to make it an additional super (windows) key.

To make this work at startup, you can put it in ~/.profile as this will only run after the interactive login.

If the switch does not persist between logins (e.g. when suspending your machine) you can also create a .xinitrc file in your home directory and put it there. Linux mint 20 on a laptop works impeccable with this option.


Okay, found a way to do this using gnome-tweak-tool.

From a terminal, run

sudo apt-get install gnome-tweak-tool -y && gnome-tweak-tool

You can find an option to swap Caps Lock and Esc in "Typing -> Caps Lock key behavior".