I used to have the caps lock and control swapped in GNOME, but when I upgraded to Ubuntu 9.04 I also changed my desktop environment to Xfce. I have the following line in my xorg.conf:

Option          "XkbOptions"    "ctrl:nocaps"

But that doesn't seem to make a difference to Xfce. Any ideas?

  • The first thing I usually do when I get a new keyboard is physically pry off the caps lock key. If you can't make it swap effectively it's a thought.
    – nedm
    Commented May 20, 2009 at 16:59

6 Answers 6


I ended up removing the "XkbOptions" line from my xorg.conf, and adding this to Xfce's autostart:

/usr/bin/setxkbmap -option "ctrl:nocaps" 

It turns the caps lock key into an additional Ctrl, which does the trick for me. If you wanted a straight swap, I believe "ctrl:swapcaps" would work. For what it's worth, this page is a fairly decent guide:


I haven't had a change to try the other methods yet, but I also have a netbook with a slightly funky layout, and I might need to muck around with it a bit.

  • 5
    Putting the above line into ~/.profile will also do the trick! (For those unfamiliar with xfce autostart)
    – Arvodan
    Commented Jun 15, 2009 at 7:42
  • Every time I restart my computer, it goes back to regular caps lock/ctrl. Also, the link is dead now.
    – Paradox
    Commented Jul 15, 2018 at 19:01
  • Fixed the link. Commented Aug 9, 2018 at 23:26
  • Unfortunately this doesn't stick. If a keyboard gets unplugged it loses the setting. This is one of my main frustrations with Xfce and I've not found a solution after years of trying, so I just rerun the setxkbmap command over and over and over and over!
    – Mike McKay
    Commented May 3, 2023 at 18:16

I use XFCE but this solution should work for any desktop environment on Debian or Ubuntu:

Replace the XKBOPTIONS definition in /etc/default/keyboard with


This affects all users on the system.

This won't affect your current session (you have to restart X11),
so you can run this command line to change things until then:

$ setxkbmap -option ctrl:nocaps

To affect only your user, have the above command run as a part of your session: Open your XFCE Settings (run xfce4-settings-manager) and click on Session and Startup, go to the Application Autostart tab, and Add that command.


Use xkeycaps to look at your keyboard mapping and swap the META and ALT modifiers, or just swap the entire keys. If you plan on using any GNOME apps, GNOME has some assumptions about which keys have META and ALT modifiers. It'll probably make your life easier to swap the keys entirely.


You could try xmodmap

I have a small netbook computer with an annoying extra key next to the left-shift key. By putting the following in ~/.Xmodmap, I can re-map the key to be another left-shift key.

keycode 94 = Shift_L
add shift = Shift_L

Perhaps you can do something similar to swap you caps-lock and control keys?

  • I'd recommend /etc/default/keyboard instead – if you have a ~/.Xmodmap, XFCE will wait like 10 seconds after login/resume/unlock before it applies its own keybindings (super-d for desktop etc, along with anything you've defined yourself). Very annoying.
    – unhammer
    Commented May 23, 2021 at 9:36

Xfce should be the same as GNOME and all other desktop environments here - what probably happened is it broke in the upgrade to Ubuntu 9.04 for all environments, since Xorg keyboard & mouse configuration options moved from xorg.conf to HAL.

More info on the new configuration methods can be found in pages such as:


The problem with all of the other answers is that if you use a USB keyboard and any USB event happens then you will lose your settings. After many years, many failed attempts and visiting this page many times I finally have a solution that survives USB events:

  1. Install inputplug

For arch this I needed to use community repos: yay -S inputplug

  1. Create a script that sets up your custom keyboard settings

Here's the script (~/on-new-kbd) I use to maps caps to control and also to set the compose key to be right control (useful for typing things like '€')

#! /bin/sh

echo >&2 "$@"
event=$1 id=$2 type=$3

case "$event $type" in
'XIDeviceEnabled XISlaveKeyboard'
        /usr/bin/setxkbmap -option 'ctrl:nocaps'
        /usr/bin/setxkbmap -option 'compose:rctrl'
  1. Make sure it runs at startup

Make it run when xfce starts by adding a new autostart entry. Do this by creating the file .config/autostart/inputplug.desktop

[Desktop Entry]
Comment=Detect new keyboards and apply settings like caps - > ctrl
Exec=/usr/bin/inputplug --bootstrap --command ~/on-new-kbd
  • On Fedora 38. There are keyboard settings for XFCE but for the life of me, I couldn't figure them out. KDE was/is so simple in that respect. This seems to be doing the trick. I went to git to obtain inputplug - and installed libbsd dev for the pkgconfig - rewrote the case statement for bash (what shell are you using?). Unplugged and re-plugged my usb keyboard - works. thanks!
    – Jim
    Commented Jun 3, 2023 at 22:53
  • Glad you got it to work - yeah this was one of my last major complaints about xfce (multiple monitors is the other). The above script is straight sh - the original POSIX shell.
    – Mike McKay
    Commented Jun 29, 2023 at 19:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .