How To Bind Any Unicode To Keys In Linux

Now that I am typing in Esperanto to others online I needed a fast way to type the characters not found in Engish. This would have been trivial if I was using a typical desktop environment like Gnome, Plasma, or KDE; but I use i3wm, and after much searching, I found this approach.

Modifying this file is prone to errors so make sure you pick the right keys to assign the new values. If you edit a key and run the command below that now becomes the new key. Upon messing up you will have to hunt down the letter online, copy, paste, and re-run the command to get the standard functionality back.

That happened to me twice last night...

This also enables these characters to appear in the terminal which is pretty cool if you ask me.

Edit: .xmodmaprc

Keycode 64 is the left alt key for my keyboard. Find keycodes your keycodes at /usr/include/X11/keysymdef.h

.xmodmaprc Syntax Order:

keycode <number> = key shifted_key mode_switch_key shifted_mode_switch_key

.xmodmaprc Example

The below keycodes are for the Programmer's Dvorak layout as my system assigned them and will be different on other keyboard layouts!

Do Not Copy & Paste This Into Your .xmodmaprc File! Use /usr/include/X11/keysymdef.h to find the keys for your specific keyboard layout as seen by your Linux distribution.

keycode 64 = Mode_switch keycode 31 = c C U0109 U0108 keycode 30 = g G U011D U011C keycode 44 = h H U0125 U0124 keycode 54 = j J U0135 U0134 keycode 47 = s S U015D U015C keycode 41 = u U U016D U016C

After creating this file and running the command below; I can now type left alt + c and get ĉ or left alt + shift + c to get Ĉ. This works in every program that I have tried so far including Firefox, Suckless' Simple Terminal, and the desktop Riot application.

To apply changes:

xmodmap ~/.xmodmaprc