Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I tried doing it like follows (in autostart):

setxkbmap -option "ctrl:nocaps"

and it works, but only for a while - then the setting is reset back to original state. How can I make it persistent?

I use xfce4-xkb-plugin as my input language switcher, but it doesn't seem to have an option to set caps key function.

share|improve this question
up vote 3 down vote accepted

Finally, I found what I was seeking for. The solution: remove xfce keyboard applet (didn't need to deinstall it, just deleting it from panel worked), install xxkb. Make sure the ~/.xxkbrc contents look something like this:

XXkb.mainwindow.geometry: 20x20+0+0
XXkb.mainwindow.label.background: black
XXkb.mainwindow.label.foreground: white
XXkb.mainwindow.label.font: -misc-*-r-*-14-*
XXkb.mainwindow.label.text.1: en
XXkb.mainwindow.label.text.2: ru
XXkb.controls.add_when_start: yes
XXkb.controls.two_state: no
XXkb.button.enable: no

And add the following to run at your session startup:

xxkb &
setxkbmap -layout us,<your layout> -option "grp:ctrl_shift_toggle,ctrl:nocaps"
share|improve this answer

Add the setxkbmap option in XKBOPTIONS in /etc/default/keyboard. That file is also when you run sudo dpkg-reconfigure keyboard-configuration, however running that command does not interactively let you choose to swap Caps Lock and Ctrl, so you will need to edit the file by hand.

share|improve this answer
I already tried that - nothing changed. – Rogach Feb 23 '13 at 20:39
Are you seeing the same thing as this blogger did?… – holmb Feb 23 '13 at 20:40
Doesn't seem so. Let me try again, I'll post the detailed symptoms of what happens when I try setting XKBOPTIONS. – Rogach Feb 23 '13 at 20:44
So, I added option, ran dpkg-reconfigure. At first, everything is great, but I lost the ability to change keyboard layout (it was deleted from layouts list). I go to keyboard applet (xfce4-xkb-plugin), set up new layout, set the key combination to change the layout (left ctrl + left shift). Now, language change works - but caps lock is back to original function. – Rogach Feb 23 '13 at 20:48

The easiest is to create a file named ~/.gconf/desktop/gnome/peripherals/keyboard/kbd/%gconf.xml with the content:

<?xml version="1.0"?>
       <entry name="options" mtime="1360937304" type="list" ltype="string">
               <li type="string">
                       <stringvalue>ctrl       ctrl:swapcaps</stringvalue>

If that file already exists, or if you prefer to do it the manual way using the GUI, click the settings cog in the top right corner, choose System Settings, then Keyboard Layout, click Options, expand Ctrl position and choose Swap Ctrl and Caps Lock.

share|improve this answer
Unfortunately, it's Xfce, not Gnome. They don't have such option in Xfce :( – Rogach Feb 23 '13 at 20:07
Oh, that is correct. My bad. – holmb Feb 23 '13 at 20:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.