How to permanently swap esc and caps lock in xfce / xubuntu?

Execute xfce4-settings-manager, in Session and Startup -> Application autostart, add an entry, which executes xmodmap ~/.xmodmap

Or rename the file to ~/.Xmodmap


xkb has an option that does just that:

caps:swapescape      Swap ESC and Caps Lock

so you could simply add1

/usr/bin/setxkbmap -option "caps:swapescape"

to your XFCE autostart items.


1: there might be a better way to do this but I'm not a XFCE user


In Xfce on Opensuse I swapped my Esc and Caps Lock keys by editing the /etc/X11/xorg.conf.d/00-keyboard.conf file as explained at the archlinux wiki. I added a line that says

Option "XkbOptions" "caps:swapescape"

to the section that starts with

Section "InputClass"

then restarted my computer and the deed was done.

Back up the file before you edit it. If you make a mistake your gui might not start and you will have to restore or edit the file from a command prompt. In Ubuntu I recall that I had to put add the option line in a keyboard configuration file that had a different name.