Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
share|improve this question

migrated from stackoverflow.com Apr 11 '13 at 17:27

This question came from our site for professional and enthusiast programmers.

add comment

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
    
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 '13 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 '13 at 16:54
add comment

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.