Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
    
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. –  xiongtx 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. –  xiongtx 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
show 1 more comment

1 Answer 1

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"

then,

source ~/.bashrc

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

share|improve this answer
add comment

Your Answer

 
discard

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.