How to permanently swap esc and caps lock in xfce / xubuntu?
Solution 1
Execute xfce4-settings-manager, in Session and Startup
-> Application autostart
, add an entry, which executes xmodmap ~/.xmodmap
Or rename the file to ~/.Xmodmap
Solution 2
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
Solution 3
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.
Solution 4
Using the .Xmodmap didn't work for me.
However, a quick man xmodmap says that this works and did:
.xmodmaprc
which can be executed:
xmodmap .xmodmaprc
EDIT: ack...I'm wrong...the default did change a few years ago to .Xmodmap from .xmodmaprc. Creating the .Xmodmap file caused my xfce to load "funny". In .bash_profile, I put:
xmodmap .xmodmaprc
Then it worked, and I have a script that restarted my Xfce so it all works.
Related videos on Youtube
Dan Ross
West Coast Canadian rocking the startup scene in the Middle East with expats from all over the world. When I'm home, I'm big on high quality bacon, local beer, and homegrown awesomeness. I'm always down for a new adventure. On the other side of the planet, I usually just tag along with the locals on whatever craziness they happen to be up to. Slowly learning the Arabic that makes up most of our data. Ma'asa Salama!
Updated on September 18, 2022Comments
-
Dan Ross over 1 year
I followed some post a while ago, and it said to make an
~/.xmodmap
file like so:! Swap caps lock and escape remove Lock = Caps_Lock keysym Escape = Caps_Lock keysym Caps_Lock = Escape add Lock = Caps_Lock
I did, and it now I can swap
esc
andcaps lock
by doingxmodmap ~/.xmodmap
. I wanted this to be permanent, so I added that command to my~/.bash_profile
, but it doesn't seem to work; I still have to manuallyxmodmap
. As an EEng dropout, I am tempted to just rewire my keyboard }:-) but I know there must be a better way. How can I make this work, permanently? -
Dan Ross about 11 yearsI renamed the file (it worked!), but I am surprised that my .bash_profile method didn't work. I thought my bash-fu was not weak :P
-
Dan Ross over 8 yearsCool, I'll give it a shot on my next reboot. Xmodmap doesn't quite work perfectly for me, I have to manually trigger it after switching keyboard languages, for example. I'm also not on XFCE anymore. That was cool, but I wanted more control at home (Arch) and better interop with the stuff my colleagues use at work (vanilla Ubuntu).
-
don_crissti over 8 years@DanRoss - Well, if you're using gnome (the only DE that I'm familiar with) it's as simple as adding
caps:swapescape
to yourxkb-options
-
G-Man Says 'Reinstate Monica' about 2 yearsdon_crissti has already posted
setxkbmap -option "caps:swapescape"
as an answer. Since the question asks how to swap Esc and Caps Lock, I wonder why you believe that this is a better answer (or even a correct one at all). Can you justify your claim that your answer works? Do you claim that you answer works better than don’s? … … … … … … … … … … … … … … … … … … … … Please do not respond in comments; edit your answer to make it clearer and more complete. Include references, if possible.