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.

When I program I like to swap these keys:

EscTab CtrlCapsLock

In ~/.xmodmap, I have specified these re-mappings:

keycode 66 = Control_L
keycode 37 = Caps_Lock
keycode 23 = Escape
keycode 9 = Tab

The Escape and Tab keys swaps, no problem, but instead of Caps_Lock and Control_L swapping, both those keys becomes Caps_Lock.

Whatever I try to do, the Control keys doesn't get assigned to Caps_Lock (keycode 66). If I leave the keycode 66 =, the key is un-assigned, but when I assign Control_L or Control_R, it just doesn't work. But, if I assign some other key, for example, keycode 66 = Tab, it gets assigned, no problem.

Its like xmodmap just doesn't want Caps Lock and Control keys to be swapped. Really frustrating. Any help/pointers would be really helpful.

P.S: I am using Archlinux.

share|improve this question

2 Answers 2

up vote 6 down vote accepted

The xmodmap(1) man page has an example for exactly this

   !
   ! Swap Caps_Lock and Control_L
   !
   remove Lock = Caps_Lock
   remove Control = Control_L
   keysym Control_L = Caps_Lock
   keysym Caps_Lock = Control_L
   add Lock = Caps_Lock
   add Control = Control_L

but if you want to finish doing it the way you started, I think you need to add at least the remove and add lines

   remove Lock = Caps_Lock
   remove Control = Control_L
   keycode 37 = Caps_Lock
   keycode 66 = Control_L
   add Lock = Caps_Lock
   add Control = Control_L

I'm guessing that's the case based on this paragraph

   add MODIFIERNAME = KEYSYMNAME ...
           This adds all keys containing the given keysyms  to  the  indi‐
           cated  modifier  map.  The keysym names are evaluated after all
           input expressions are read to make it easy to write expressions
           to swap keys (see the EXAMPLES section).

which makes it sound like modifier changes (shift, control, etc.) don't get applied until you run that too.

(And logically the same with remove)

share|improve this answer
    
I did read the manpage, and re-assigned the Caps_Lock and Control_L keys following the example. But, I was curious why re-mapping the keys the way mentioned in the OP doesn't work. Is it a bug or something? –  gits1225 Apr 12 '12 at 6:52
    
Seems it's just the way it's supposed to work. See my updated answer. –  Mikel Apr 12 '12 at 6:55

Loosely related answer: I wanted to remap the caps lock key to left control, leaving the actual left control untouched. The xmodmap man page also offers the solution:

    keycode 66 = Control_L
    clear Lock
    add Control = Control_L
share|improve this answer

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.