I want to swap the Ctrl and Caps Lock keys on my keyboard. I go to System Settings -> Keyboard -> Layout Settings -> Options and check Swap Ctrl and Caps Lock under Ctrl Key Position. I check that my keyboard ( English US) has the new key bindings.

However, when I exit settings, the keybindings switch back to default. How can I make my custom settings stay? I don't see a "Save" button anywhere.

  • There is no Save button in Gnome. After you change the setting, it should become effective immediately. – Mikel Apr 21 '12 at 23:00
  • @Mikel I know, that's why I'm confused as to how I can make the changes permanent. – Tianxiang Xiong Apr 21 '12 at 23:03
  • WFW on Fedora 16. What version of Fedora are you using? – Mikel Apr 21 '12 at 23:04
  • What does WFW mean? I'm using Fedora 16, as noted in the title. I don't know what other version you're talking about. – Tianxiang Xiong Apr 21 '12 at 23:07
  • Sorry, I mean to write WFM meaning Works For Me. So I don't understand why it's not working for you. Need more details. Are you using multiple locales? Is there anything non-standard about your setup? – Mikel Apr 22 '12 at 1:34

Setting the x keymap directly using the command line is by far my preferred way of dealing with keymaps, and it's very disto-agnostic, so any solution you come up with will stand you in good stead.

Try this:

setxkbmap -print | xkbcomp -xkb -o original.xkb -

this will make a backup of your original keymap. Then do

cp original.xkb switch-CAPS-LCTL.xkb

Now edit switch-CAPS-LCTL and find the lines that read

<CAPS> = ??;
<LCTL> = ??;

where ?? is a number. On mine, these are two digit numbers, 66 and 37 respectively. Just switch them around and you're done.

xkbcomp switch-CAPS-LCTL.xkb $DISPLAY 

switches the layout, and

xkbcomp original.xkb $DISPLAY 

will restore the old configuration.

If you are going to be using these two keymaps concurrently, for maximum user-friendliness, just make two aliases to handle these keymap changes, and plop the keymaps into a hidden directory like ~/.stuff

mkdir ~/.stuff
mv original.xkb switch-CAPS-LCTL.xkb ~/.stuff
nano ~/.bashrc

Add the following to ~/.bashrc:

alias capswitch="xkbcomp ~/.stuff/switch-CAPS-LCTL.xkb $DISPLAY"
alias ctrlswitch="xkbcomp ~/.stuff/original.xkb $DISPLAY"


source ~/.bashrc

if you want the changes to take effect immediately, typing capswitch and ctrlswitch to change the keymap.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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