24

I used to have the caps lock and control swapped in GNOME, but when I upgraded to Ubuntu 9.04 I also changed my desktop environment to Xfce. I have the following line in my xorg.conf:

Option          "XkbOptions"    "ctrl:nocaps"

But that doesn't seem to make a difference to Xfce. Any ideas?

Marcel Levy
  • 713
  • 1
  • 7
  • 11
  • The first thing I usually do when I get a new keyboard is physically pry off the caps lock key. If you can't make it swap effectively it's a thought. – nedm May 20 '09 at 16:59

5 Answers5

37

I ended up removing the "XkbOptions" line from my xorg.conf, and adding this to Xfce's autostart:

/usr/bin/setxkbmap -option "ctrl:nocaps" 

It turns the caps lock key into an additional Ctrl, which does the trick for me. If you wanted a straight swap, I believe "ctrl:swapcaps" would work. For what it's worth, this page is a fairly decent guide:

http://manicai.net/comp/swap-caps-ctrl.html

I haven't had a change to try the other methods yet, but I also have a netbook with a slightly funky layout, and I might need to muck around with it a bit.

Marcel Levy
  • 713
  • 1
  • 7
  • 11
9

I use XFCE but this solution should work for any desktop environment on Debian or Ubuntu:

Replace the XKBOPTIONS definition in /etc/default/keyboard with

XKBOPTIONS="ctrl:nocaps"

This affects all users on the system.

This won't affect your current session (you have to restart X11),
so you can run this command line to change things until then:

$ setxkbmap -option ctrl:nocaps

To affect only your user, have the above command run as a part of your session: Open your XFCE Settings (run xfce4-settings-manager) and click on Session and Startup, go to the Application Autostart tab, and Add that command.

Adam Katz
  • 869
  • 8
  • 16
2

Use xkeycaps to look at your keyboard mapping and swap the META and ALT modifiers, or just swap the entire keys. If you plan on using any GNOME apps, GNOME has some assumptions about which keys have META and ALT modifiers. It'll probably make your life easier to swap the keys entirely.

Brent
  • 22,219
  • 19
  • 68
  • 102
shapr
  • 437
  • 7
  • 12
2

You could try xmodmap

I have a small netbook computer with an annoying extra key next to the left-shift key. By putting the following in ~/.Xmodmap, I can re-map the key to be another left-shift key.

keycode 94 = Shift_L
add shift = Shift_L

Perhaps you can do something similar to swap you caps-lock and control keys?

Brent
  • 22,219
  • 19
  • 68
  • 102
  • I'd recommend /etc/default/keyboard instead – if you have a ~/.Xmodmap, XFCE will wait like 10 seconds after login/resume/unlock before it applies its own keybindings (super-d for desktop etc, along with anything you've defined yourself). Very annoying. – unhammer May 23 '21 at 09:36
2

Xfce should be the same as GNOME and all other desktop environments here - what probably happened is it broke in the upgrade to Ubuntu 9.04 for all environments, since Xorg keyboard & mouse configuration options moved from xorg.conf to HAL.

More info on the new configuration methods can be found in pages such as:

alanc
  • 1,500
  • 9
  • 12