Using Xmodmap to map one key to another

So, everybody having a good holiday?? As for me, I got unlucky with my super sleek and shiny laptop and its motherboard got fried. So, for quite some time I was relegated to using a laptop which

(i) had a Spanish keyboard, on top of which I was using German and English layouts (oh yes, even for programming ;-)), and

(ii) had the period/colon key missing (it had been ripped off), so I was using another keyboard connected via a USB port to type my periods and colons whenever they came up. And no, I could not only use the USB keyboard because that one in turn had some keys not in the best working order (!!! wait, it gets better soon !!!)

After bearing with all this for quite some time, I thought there has to be some way I can map the period/colon key to one of the keys I am not using, for example Pause, F12 etc., and do away with the additional USB keyboard, and thus make things a little better. So I finally stumbled upon Xmodmap, which my Ubuntu was pre-equipped with, of course, and figured out a simple way to accomplish the task at hand.

Use the following at the command line:

xmodmap -e "keysym Pause = period"
xmodmap -e "keysym F12 = colon"

And you’re done! Now Pause prints the period and F12 prints the colon, no matter whether you are using the German, English or Spanish layout. I guess if you put “period colon” together then the later character will be printed with shift, but I didn’t experiment with that.

I tried putting these lines in my .xinitrc file and then in my .profile, but for some reason it doesn’t seem to be running automatically when the computer boots. For the time being I am having to do it manually every ime the computer starts afresh.

Here is a list of all the “keysym” codes you can use with Xmodmap!

There you are – happy Xmodmapping 😉