2

I followed xmodmap way of swapping ESC and Caps lock in this link. It works well when I load .bashrc with . ~/.bashrc for the first time. However, if I edit different part of my .bashrc and reload it with same command, two keys are swapped back to original mapping. Why is this happening?

Portion of my .bashrc file

...
xmodmap ~/.speedswapper
...

My ~/.speedswapper script

remove Lock = Caps_Lock
keysym Escape = Caps_Lock
keysym Caps_Lock = Escape
add Lock = Caps_Lock

1 Answer 1

2

This happens because ~/.bashrc is called every time you open a new terminal. You should put xmodmap ~/.speedswapper to some file that is executed once you log into your machine. I prefer to have it present in ~/.xinitrc

A better way would be to put the swap code under ~/.Xmodmap which is executed correctly. But it has always been flaky to me.

2
  • Thanks a lot! I placed the codes in ~/.Xmodmap, and it's working like charm. I still don't get why .bashrc getting loaded twice resets the swap...I'm fairly new to bash...
    – kidonchu
    Apr 11, 2013 at 13:58
  • @kidonchu Because that code is executed on second load as well. If you load .bashrc again, it'll swap those keys again. Try loading it three times.
    – Waseem
    Apr 11, 2013 at 16:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.