How To Assign Special Characters To Keys In Ubuntu and Linux – Part 2

Oe-char-xmodmapNote: This is not the typical post on this blog entry as you will see but I couldn't find the information I put together below easily so I hope a search engine will make this easier for others searching how to map characters to keys in Linux in the future.

Two years ago I was faced with the problem of assigning language specific characters to a key on the keyboard from a language other than what was currently used. After a lot of searching I came up with the xmodmap command in Linux that does the job nicely. At the time I only needed to assign basic Latin character set. My hack didn't work however for characters in extended character sets that do not have names assigned to characters but just a number. So I had to go looking if and how such characters can be mapped with xmodmap as well.

Once you know it, the answer is actually quite simple, just use the UTF number in hexadecimal format assigned to the character with the xmodmap command. Here's an example that maps the combined "oe" character used in French to the right-ALT + 'o' key:

xmodmap -e "keycode 32 = o O o O U0153 U0152 U0153 U0152"

Which of course raises the question of how to find the character code in the first place!? The easiest way I could come up with is to use Libreoffice's "Insert – Special Character" functionality as shown in the screenshot on the right. And to get upper and lower case mappings of the character use the corresponding adjacent character numbers from the table.