Scripting a permanent CTRL / CAPS swap in Gnome?

Posted by Duncan Bayne on Super User See other posts from Super User or by Duncan Bayne
Published on 2011-03-03T23:41:29Z Indexed on 2011/03/07 0:12 UTC
Read the original article Hit count: 220

Filed under:
|
|

I have a bash script that I use to configure a vanilla Ubuntu (10.10 Maverick Meerkat) installation to be exactly the way I want it. I make extensive use of gconftool-2 to configure the desktop, set up shortcut keys, etc.

Now, I'm trying to swap the CTRL and CAPS keys. I have found two ways of doing this:

  • In Gnome, go to System -> Preferences -> Keyboard -> Layout -> Options and make the change in there. This works well, but I don't know how to script this; the setting doesn't seem to be stored in the usual place as I can't find it with gconf-editor.

  • Add the line setxkbmap -option "ctrl:swapcaps" to my .bashrc file. That works too, until I suspend the machine & then resume it. At that point the CTRL and CAPS behaviour return to normal, until I cause .bashrc to be run again by opening a new shell. This behaviour has been reported as a bug in RedHat.

Could someone please suggest a way of switching those keys that is both permanent, and can be scripted? I'm sure I must be missing something obvious here ...

© Super User or respective owner

Related posts about ubuntu

Related posts about gnome