Remap keys using setxkbmap

Remap CapsLock to Escape and AltGr to Alt:

setxkbmap -option caps:escape,lv3:ralt_alt

Reset with:

setxkbmap -option

Persistence Link to heading

Set XkbOptions in /etc/X11/xorg.conf.d/00-keyboard.conf:

Section "InputClass"
  Identifier "system-keyboard"
  MatchIsKeyboard "on"
  Option "XkbLayout" "gb"
  Option "XkbModel" "pc105"
  Option "XkbOptions" "caps:escape,lv3:ralt_alt"
EndSection

Now restart your machine.

Alternative Link to heading

If the above did not work try /etc/default/keyboard:

XKBMODEL="pc105"
XKBLAYOUT="gb"
XKBVARIANT=""
XKBOPTIONS="caps:escape,lv3:ralt_alt"

BACKSPACE="guess"

You can either restart or execute:

sudo udevadm trigger --subsystem-match=input --action=change

Documentation Link to heading

There is none, you can look at these options listed here:

cat /usr/share/X11/xkb/rules/base.lst

Stare at them for a few hours, try some out, and you might stumble upon something useful.