(This answer is about xmodmap only. I'm sure it's possible to do this with XKB, I just don't know how.)
Modifiers and keysyms are assigned independently. But you get strange effects if you don't set them consistently. I think all you're missing is the add
command to assign a modifier to Meta_L
, though you may also need to clear and reassign the modifier keys. You may replace Mod1
and Mod2
by Mod3
, Mod4
and Mod5
: they are interchangeable, just make sure you don't use one for two different purposes.
clear Mod1
clear Mod2
remove Lock = Caps_Lock
keysym Caps_Lock = Alt_L
keysym Alt_L = Meta_L
add Mod1 = Alt_L Alt_R
add Mod2 = Meta_L Meta_R
I think I have a technique for disabling the toggling of the Capslock key but not completely disabling the key all together, or remapping it to another key on the keyboard.
If you use the command:
setxkbmap -option caps:none
The keyboard will no longer toggle. I've confirmed this on my laptop running Fedora 14, the LED no longer lights up, and normal Capslock functionality is gone.
However using xev still shows that the key is being pressed:
$ xev
...
...
KeyPress event, serial 35, synthetic NO, window 0x6800001,
root 0xb1, subw 0x0, time 261504852, (167,-15), root:(353,268),
state 0x10, keycode 66 (keysym 0xffffff, VoidSymbol), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 35, synthetic NO, window 0x6800001,
root 0xb1, subw 0x0, time 261504971, (167,-15), root:(353,268),
state 0x10, keycode 66 (keysym 0xffffff, VoidSymbol), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
...
So the key being pressed events are still left intact for other applications to pick them up.
setxkbmap
The file /usr/share/X11/xkb/rules/xorg.lst
contains the complete list of what options you can give to setxkbmap
.
Grepping through this file for "cap" I noticed this line:
caps:none CapsLock is disabled
There are other values in this file so if this isn't what you're after perhaps one of those alternate values would suite instead.
$ grep cap /usr/share/X11/xkb/rules/xorg.lst
grp:caps_switch CapsLock (while pressed), Alt+CapsLock does the original capslock action
grp:caps_toggle CapsLock
grp:shift_caps_toggle Shift+CapsLock
grp:shift_caps_switch CapsLock (to first layout), Shift+CapsLock (to last layout)
grp:alt_caps_toggle Alt+CapsLock
lv3:caps_switch CapsLock
lv3:caps_switch_latch CapsLock (chooses 3rd level, latches when pressed together with another 3rd-level-chooser)
ctrl:nocaps Make CapsLock an additional Ctrl
ctrl:swapcaps Swap Ctrl and CapsLock
grp_led:caps CapsLock
caps CapsLock key behavior
caps:internal CapsLock uses internal capitalization. Shift "pauses" CapsLock
caps:internal_nocancel CapsLock uses internal capitalization. Shift doesn't affect CapsLock
caps:shift CapsLock acts as Shift with locking. Shift "pauses" CapsLock
caps:shift_nocancel CapsLock acts as Shift with locking. Shift doesn't affect CapsLock
caps:capslock CapsLock toggles normal capitalization of alphabetic characters
caps:numlock Make CapsLock an additional NumLock
caps:swapescape Swap ESC and CapsLock
caps:escape Make CapsLock an additional ESC
caps:backspace Make CapsLock an additional Backspace
caps:super Make CapsLock an additional Super
caps:hyper Make CapsLock an additional Hyper
caps:shiftlock CapsLock toggles Shift so all keys are affected
caps:none CapsLock is disabled
compose:caps CapsLock
shift:breaks_caps Shift cancels CapsLock
shift:both_capslock Both Shift-Keys together toggle CapsLock
shift:both_capslock_cancel Both Shift-Keys together activate CapsLock, one Shift-Key deactivates
References
Best Answer
You'll have to edit your console keymap. On my console, I have mapped Escape to Caps Lock and Caps Lock to Escape. Here's how it works.
/usr/share/keymaps/i386/qwerty/us.map.gz
.us-nocaps.map.gz
.gunzip us-nocaps.map.gz && vim us-nocaps.map
keycode 58 = Caps_Lock
which I changed tokeycode 58 = Escape
.gzip us-nocaps.map && loadkeys us-nocaps
.One more thing: You'll probably have to configure your distribution somehow to make sure the new keymaps always gets loaded on boot, otherwise you'll have to load your keymap manually with
loadkeys
all time. How you do that depends on what distribution you're using.