Every Tamil keyboard layout I found maps Tamil letters onto Latin sounds. I wanted the opposite: key positions that follow the Tamil alphabet itself.
The layout was the easy part. Two Linux plumbing bugs were not.
Repo: https://github.com/prasanth-nature/tamil-keyboard
The idea
Tamil organises its script in a fixed order — உயிர் (vowels), மெய் (consonants), உயிர்மெய் (combinations). So why not put the keys in that order?
| Row | Keys | Letters |
|---|---|---|
| Top | q w e r t y u i o p |
வ ழ ள ங ஞ ண ந ம ன ஃ |
| Home | a s d f g h j k l |
க ச ட த ப ற ய ர ல |
| Bottom | z x c v b n m |
அ இ உ எ ஒ ஐ ஔ |
Every group stays together:
| இனம் | Letters | Where |
|---|---|---|
| வல்லினம் (hard) | க ச ட த ப ற | home row, left |
| இடையினம் (middle) | ய ர ல | home row, right |
| இடையினம் (middle) | வ ழ ள | top row, left |
| மெல்லினம் (soft) | ங ஞ ண ந ம ன | top row |
| ஆய்தம் | ஃ | top row, last |
26 keys = 5 குறில் + 2 diphthongs + 18 மெய் + 1 ஆய்தம்.
If you can recite the alphabet, you can type. No lookup table to memorise.
Composition: one letter, not two
Tamil writes க + இ as கி — one grapheme. A layout that emits க then இ produces கஇ, which is wrong.
So the engine remembers the last consonant and converts the next vowel into its sign:
class Composer:
def __init__(self):
self.pending = None # consonant the next vowel sign may attach to
def feed(self, key, caps=False, shift=False):
if not key or len(key) != 1:
return None
k = key.lower()
if not ("a" <= k <= "z"):
return None
if shift and k in SHIFT: # grantha letters, lone virama
out = SHIFT[k]
self.pending = None if out == VIRAMA else out
return out
if k in INDEPENDENT: # a vowel key
index = 1 if caps else 0
if self.pending is not None: # ...attached to the last consonant
sign = SIGNS[k][index]
self.pending = None
return sign
return INDEPENDENT[k][index]
out = BASE[k] # a consonant
self.pending = None if out == AYTHAM else out
return out
Caps Lock selects the long vowel (நெடில்). Anything that is not a letter — space, digits, punctuation, Ctrl/Alt — clears the pending consonant and passes through untouched.
Why not an XKB layout?
| Option | Verdict |
|---|---|
| XKB symbols file | no state between key presses — cannot turn ச + இ into சி |
| Compose file + dead keys | needs 18 custom dead keysyms, and Caps Lock still would not work as a long-vowel switch |
| IBus engine | full state machine — four dictionaries of layout data plus a thin engine |
XKB maps a keycode to a keysym. That is a lookup, not a grammar. Tamil needs the previous key.
Bug 1: the D-Bus name mismatch
The component file tells IBus how to start your engine:
<component>
<name>org.local.IBus.TamilCustom</name>
<exec>/home/me/.local/share/tamil-keyboard/ibus-engine-tamil-custom --ibus</exec>
My engine claimed a different name:
BUS_NAME = "org.freedesktop.IBus.TamilCustom"
| Symptom | Cause |
|---|---|
| layout listed in Settings | the input source was written to gsettings |
| typing did nothing | the daemon started the process, waited for a bus name nobody claimed, never attached |
entry showed the raw id tamil-custom
|
GNOME could not read the engine description, so it fell back to the id |
Fix: one string, same on both sides. Obvious in hindsight, invisible when the UI says "installed".
Bug 2: the directory IBus never scans
The component file was installed to:
~/.local/share/ibus/component/tamil-custom.xml
That path is scanned by nothing. IBus only reads /usr/share/ibus/component, and the user-directory scan is compiled out of ibusregistry.c. A $HOME path is not a default — the maintainer's position is that local component paths are a security concern.
sudo install -m 644 ~/.local/share/ibus/component/tamil-custom.xml \
/usr/share/ibus/component/
rm -rf ~/.cache/ibus/bus/registry
ibus write-cache
ibus restart
The lesson: "installed" is not "registered". Verify with the tool, not the UI:
ibus list-engine | grep tamil-custom
If that prints nothing, the layout does not exist as far as IBus is concerned — whatever Settings shows.
Lesson: resolve keys by keycode, not keysym
A related trap, if you ever ship a matching XKB layout so GNOME's View Keyboard Layout shows your letters.
Once the engine advertises layout=yourlayout, the compositor sends that layout's keysyms — வ instead of q. A keysym-based engine breaks instantly.
Resolve the physical key instead:
KEYCODES = {
24: "q", 25: "w", 26: "e", 27: "r", 28: "t",
38: "a", 39: "s", 40: "d", 41: "f", 42: "g",
52: "z", 53: "x", 54: "c", 55: "v", 56: "b",
}
def key_for(keycode, keyval):
key = KEYCODES.get(keycode)
if key is not None:
return key
if 0 < keyval < 0x110000 and chr(keyval).isascii():
return chr(keyval).lower()
return None
Keycode = which physical key. Keysym = what the current layout claims it produces. For an input method, the first one is what you want.
Tests
The layout is data, so it is testable without a desktop:
python3 tests/test_tamil_core.py # 183 assertions
python3 src/ibus-engine-tamil-custom --selftest
The suite asserts every cell of the மெய் + உயிர் table — all 18 consonants against 12 vowels — plus the Shift layer, Caps Lock forms, and pass-through behaviour.
CI runs the same on every push.
Install
git clone https://github.com/prasanth-nature/tamil-keyboard.git
cd tamil-keyboard
./install.sh --add-source
AlmaLinux, RHEL, Fedora, Debian — GNOME on Wayland or X11. MIT licensed.
There is also a doctor.sh that checks the things that break: session, Python bindings, component location, name match, layout logic, IBus registry, GNOME sources, engine log. It exists because several of those failed for me.
Links
- Repo: https://github.com/prasanth-nature/tamil-keyboard
- Reference image: https://github.com/prasanth-nature/tamil-keyboard/blob/main/Tamil%20Keyboard%20Layout%20Reference.png
- Tamil script: https://en.wikipedia.org/wiki/Tamil_script
- IBus: https://github.com/ibus/ibus
If you type Tamil on Linux, I would like to know whether the alphabet ordering is faster to learn than Tamil99 — that is the one claim I cannot test myself.
Top comments (0)