14

as many others I don't need CapsLock. I want to reassign it such that it has the function of AltGr. I use Kubuntu 9.10 but I think there must be a solution which is distribution independent.

I already tried to use setxkbmap or xmodmap. Using xmodmap at least I managed that CapsLock to behaves like Del by following this description.

But I could not achieve assigning the AltGr behavior to CapsLock.

5 Answers 5

14

I know this question is old, but if anyone stumbles across it again, there is an alternative solution:

setxkbmap -option "lv3:caps_switch"

For a full list of options, read the "OPTIONS" section of

man xkeyboard-config
6

Based on Dennis' answer and by playing around with xev I found out that the magic phrase seems to be ISO_Level3_Shift.

At least this works for me:

xmodmap -e "keycode 66 = ISO_Level3_Shift"

Now I dont' run into danger to break my fingers while typing [, ], {, } and co on my german keyboard layout.

Edit: now using the -e option of xmodmap

1
  • Thanks! I've been looking for exactly this since moving to Ubuntu from Windows. Without this JavaScript is a pain on a German keyboard.
    – gzost
    Feb 12, 2016 at 14:17
3

Long's answer is the best one for modern Desktops like Gnome, because Gnome itself uses xkb and overwrites xmodmap configurations by default (also, xmodmap is on its way out and unsupported in Wayland). Unfortunately, it will still only work until reboot.

You can apply this option permanently for your Gnome desktop with this command:

gsettings set org.gnome.desktop.input-sources xkb-options "['lv3:caps_switch']"

Of course you can also make this change permanently and even system wide, without using Gnome. If you use Gnome, you should still use the above command to keep Gnome from overwriting this setting. For Arch, you can add a file /etc/X11/xorg.conf.d/90-custom-kbd.conf with the following content:

Section "InputClass"
    Identifier "keyboard defaults"
    MatchIsKeyboard "on"
    Option "XKbOptions" "lv3:caps_switch"
EndSection

I assume this differs between distributions, so your mileage might vary.

1

Try one of these (substitute the keysim or keycode of your caps-lock key if it's different):

xmodmap -e "keysym 0xffe5 = Mode_switch"

or

xmodmap -e "keycode 66 = Mode_switch"
3
  • Thanks. Your line did not work directly for two reasons: 1. xmodmap wants a file so I have to pipe the string and read from stdin. 2. Mode_switch was successfully assigned but did not result in the 3rd level modifier. Then I played with xev again. When I realized that the string "Mode_switch" showes up there it was easy to press AltGr and look what one could read instead in the corresponding place. -> ISO_Level3_Shift.
    – cknoll
    May 7, 2010 at 14:38
  • @basweber: I forgot the -e option. I've edited my answer. May 7, 2010 at 15:13
  • Yes. Thats much cleaner than the piping approach.
    – cknoll
    May 8, 2010 at 20:20
0

Unfortunately, solutions offered above did not work for me. So I found a clear way to adjust any key with a minimum "magic under the hood".

  1. Open file '/usr/share/X11/xkb/symbols/us' (or other locale you use) in sudo mode file.
  2. Find a chapter with your layout. I use Colemak, so for me it starts at line // Colemak symbols for xkb on X.Org Server 7.x
  3. Replace include "level3(ralt_switch)" with include "level3(caps_switch)", save changes.
  4. Reboot x server to apply the changes.

My initial idea was to set vims 'hjkl arrows' to my Colemacs 'neio' in third level (i.e. keys under right hand works as arrow while CapsLock is pressed). I reach it with next reconfiguring:

key { [ n, N, KP_Left, Ntilde ] }; key { [ e, E, KP_Down, Eacute ] }; key { [ i, I, KP_Up, Iacute ] }; key { [ o, O, KP_Right, Oacute ] };

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.