How to remap CapsLock to Ctrl in Xubuntu 12.04?

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.


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.


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"