Last updated: 2026-10-20 (0.33: multilingual input methods, Zhuyin candidate picking)
Why write our own
Pomelo used to rely on fcitx5 or ibus for typing Chinese. Measured on a clean Pomelo install, this is what they add:
| Option | Extra packages | Extra space | Resident memory |
|---|---|---|---|
| fcitx5 + Chewing (no recommended packages) | 49 | about 37 MB | about 30 MB |
| ibus + Chewing | 79 | about 235 MB (pulls in GTK, Python) | about 28 MB in two processes |
| pomelo-input | 5 | about 4 MB | about 6 MB |
The extra 37 MB is hunspell, enchant, pango, gdk-pixbuf, wayland and other things unrelated to Zhuyin.
Available input methods
With Zhuyin only, users whose interface is in Simplified Chinese, Japanese, Korean or Vietnamese still had to install fcitx5. 0.33 restructures pomelo-input around
"engines" (pomelo-input/engine.h), one engine per language:
| Engine (id in settings) | Menu bar | How | Packages needed |
|---|---|---|---|
Zhuyin (chewing) |
注 | libchewing (Chewing), linked directly | installed with pomelo-input |
Pinyin (Simplified) (rime-pinyin) |
拼 | librime, schema luna_pinyin_simp |
librime + downloaded schema data |
Cangjie (rime-cangjie) |
倉 | librime, schema cangjie5 |
same as above |
Quick (rime-quick) |
速 | librime, schema quick5 |
same as above |
Jyutping (rime-jyutping) |
粵 | librime, schema jyut6ping3 |
same as above |
Japanese (anthy) |
あ | romaji→kana done in-house, kana→kanji by Anthy | anthy (anthy-unicode on Fedora/Rocky) |
Korean (hangul) |
한 | libhangul | libhangul |
Vietnamese (viet) |
V | Telex/VNI rules written in-house | none |
- Libraries other than Zhuyin's are dlopened at run time (
libhangul.so.1,librime.so.1,libanthy.so.1orlibanthy-unicode.so.0), so the pomelo-input package doesn't depend on them; engines not installed on the system show "Install" on the settings page, and one click installs them in a terminal withinstall-min(no recommended packages). Package names differ between Ubuntu 22.04/24.04/26.04 (librime1orlibrime1t64), so the settings page usesapt-cache showto pick the one this system has. - Input methods turned on by default for the interface language (while
input.engineshasn't been set by the user): Traditional Chinese → Zhuyin, Simplified Chinese (zh_CN, zh_SG) → Pinyin, Hong Kong and Macau (zh_HK, zh_MO) → Cangjie + Quick, Japanese → Japanese, Korean → Korean, Vietnamese → Vietnamese; nothing for other languages. pomelo-input and pomelo-language each have a copy ofdefault_engines(); change them together.
Rime (Pinyin, Cangjie, Quick, Jyutping)
- Only the structures defined in
rime_api.hare used from librime's API, so librime 1.10.0's header is kept inpomelo-input/third-party/(BSD-3-Clause) and librime-dev isn't needed to build. - Schema data is downloaded by Pomelo itself: Fedora's librime ships no schemas, and Ubuntu's rime-data-* versions follow the distribution,
so every distribution downloads files at a pinned commit from GitHub and checks their size and SHA256 (the table is
rime_filesinpomelo-language.c). They go in$XDG_DATA_HOME/pomelo/rime-data; user data (compiled dictionaries, learned words) goes in$XDG_DATA_HOME/pomelo/rime, separate from fcitx's and ibus's Rime. Files per schema: Pinyin 10.2 MB (prelude, essay, luna_pinyin, stroke), Cangjie 0.8 MB more, Quick 0.07 MB more, Jyutping 11.8 MB more (Cangjie and Jyutping use each other for reverse lookup). - Downloading runs in a background thread on the settings page (
curlfetches one file at a time, with a percentage on the right), and the input method is ticked automatically when done. Note thatpm_ui_runreaps child processes automatically (SIGCHLD ignored), so curl's exit code isn't available; success is judged by file size and SHA256. - When pomelo-input starts, or when settings change (for example right after a download), it writes
default.custom.yaml(schema list, candidates per page) into the user folder; only if the content changed does it callstart_maintenance(True)to "deploy" in the background (compiling dictionaries, a dozen seconds or so the first time). Keys go to the program as usual while deploying, and the candidate bar shows "Preparing input method…"; after deployment the session is reopened with the new "generation". - Simplified Pinyin needs OpenCC's Traditional-to-Simplified configuration: librime looks in the schema folder's
opencc/, so a symlink to/usr/share/openccis created (Ubuntu's libopencc-data and Fedora's opencc are both installed along with librime). - Candidate comments (Jyutping pronunciations, Cangjie completion codes) are drawn after the candidate in smaller gray text.
- Rocky 9 has no librime (not in EPEL either): these four show "Not available on this system" on the settings page.
Japanese (Anthy)
- Romaji → hiragana uses our own table (
eng-anthy.c), like ordinary Japanese input methods:konnnichiha→こんにちは,kitte→きって (a doubled consonant becomes っ), the n inkanjifollowed by a consonant becomes ん,nn/n'are both ん,-→ー,,.→、。. - Space hands the kana to
anthy_set_string()for segmented conversion; ←→ switch segments, Shift+←→ change a segment's length, Space/↑↓ change candidates, digit keys pick directly (picking in the last segment commits), Enter commits (anthy_commit_segment()for each segment, so Anthy learns), Esc/Backspace go back to kana, F6 hiragana, F7 katakana. The 「半角/全角」 and 「変換」 keys on Japanese keyboards work too. - Debian/Ubuntu's anthy (1:0.4) and Fedora/Rocky's anthy-unicode have the same function names; both are set to UTF-8 first.
Korean (libhangul)
- Letter keys go to
hangul_ic_process(); digits, punctuation, Space, Enter and arrow keys first commit the half-composed syllable and then go to the program. - Keyboards: 2-set (default), 3-set (final), 3-set (390), Romaja (
input.hangul_kb). The 「한/영」 key on Korean keyboards switches. - With Caps Lock on, X gives uppercase, but uppercase in 2-set means double consonants, so case is decided by Shift.
Vietnamese (Telex, VNI)
- Written in-house (
eng-viet.c, about 270 lines), no library needed. One syllable stays in the composition area and is committed on Space, punctuation or Enter. - Telex: aa â, aw ă, ee ê, oo ô, ow ơ, uw ư, w ư, dd đ; s f r x j for tones, z removes the tone. VNI: 6 â ê ô, 7 ơ ư, 8 ă, 9 đ; 1–5 for tones, 0 removes the tone. Pressing the same key twice cancels it (ass→as).
- Tone placement follows the traditional rules: on â ê ô ă ơ ư if present (on ơ for ươ); with two vowels and no final consonant, on the first (hòa, thủy, của), with a final consonant, on the second (toán); with three vowels, on the middle one (khoái); the u and i of qu and gi count as consonants (quốc, giữ).
- Backspace deletes the last letter, and the tone moves to where it belongs (việt→việ).
input.viet= telex (default) or vni.
How it works
- Programs talk to it over the XIM protocol, implemented with libxcb-imdkit (fcitx5's own XIM frontend uses it too).
pomelo-input is an XIM server registered as
@server=pomeloin the root window'sXIM_SERVERS; programs just need the environment variableXMODIFIERS=@im=pomelo(plusGTK_IM_MODULE=ximfor GTK programs), which pomelo-session sets. - No trigger keys are registered: every key goes to the server, and the engine decides whether to consume it or pass it back unchanged (key releases are always passed back). Whether or not the engine consumes it, text to be committed is sent first and the unconsumed key passed back afterwards, so the order is right.
- State is kept on the root window:
_POMELO_INPUT_MODE(zh = input method, en = English; empty when no input method is on),_POMELO_INPUT_LABEL(the character on the menu bar: 注, 拼, あ, 한, V…),_POMELO_INPUT_ENGINES(one line each: "id<Tab>character<Tab>name<Tab>1 = current"). The menu bar draws the indicator from these (English mode draws 「英」, translated as EN or A in other languages), and clicking it lists every enabled input method;pomelo-input --toggle/--next/--engine IDnotify the server through the root properties_POMELO_INPUT_TOGGLEand_POMELO_INPUT_SELECT. - The candidate bar is a small override-redirect window we draw ourselves with cairo-xcb, following
XNSpotLocation(placed at the bottom left of the window when the program gives no cursor position); the first row is the composition area (converted text + the part being typed in the accent color + cursor), the second the candidates, the third a hint. Dark mode and accent color follow the system settings and apply immediately when changed. - Each input context (IC) has one context per engine (created on first use), all freed when the program closes.
Picking candidates (0.33 improves it for Zhuyin)
- While the candidate bar is open, ←→ move the highlight (turning to the previous/next page at either end), Enter picks the highlighted one, and digit keys pick directly.
- The candidate under the mouse is highlighted and a click picks it; the scroll wheel turns pages. The page count "2/5" is shown on the right ("2 ›" when Rime doesn't report the total).
- libchewing 0.5 has no
chewing_ack():commit_Checkstays 1 until the next key Chewing handles, sotakenremembers that this text was already sent; keys Chewing doesn't handle, such as Ctrl and F5, must not clear it, or the previous text would be sent again.
Usage
- Tap Shift (no other key within 400 ms) or Ctrl+Space: input method/English; switching to English commits the composition first.
- Ctrl+Shift+Space: next input method (in
input.enginesorder); the indicator on the menu bar can pick one too. - 「한/영」 on Korean keyboards and 「半角/全角」 on Japanese keyboards: input method/English.
- Zhuyin: Shift+Space full-width/half-width; Space/↓ opens candidates; Esc clears; ←→ move the cursor, Shift+←→ select a phrase range, Ctrl+digit adds a phrase (all standard libchewing behavior).
Qt apps (since 0.33, ibus.c)
Qt5/Qt6 have no XIM and recognize only the IBus and fcitx plugins; the IBus plugin (libibusplatforminputcontextplugin.so) comes with Qt itself,
so there's nothing else to install. So pomelo-input also speaks IBus' D-Bus protocol:
- It uses libdbus to open a small "bus" with only itself as a service (
$XDG_RUNTIME_DIR/pomelo-input-ibus-<顯示器>, using an abstract socket when the path is too long; accepting only the same user), and writes the address into~/.config/ibus/bus/<machine-id>-unix-<顯示器編號>(Qt looks for this file following ibus-daemon's rules, and also checks that theIBUS_DAEMON_PIDinside it is still alive); it is deleted on exit (only if we were the one who wrote it). - It answers the bus methods (Hello, GetNameOwner, AddMatch…); its own unique name is
:1.0, and signals are all marked as sent from:1.0(Qt uses this to match them). CreateInputContext→/org/freedesktop/IBus/InputContext_N;ProcessKeyEvent(keyval, keycode, state)is handed to the samehandle_keyas XIM (IBus' low 8 modifier bits are the same as X's, Super/Meta count as Mod4, and1<<30means release); the typed text is sent with theCommitTextsignal, ahead of the ProcessKeyEvent reply, so the app receives the text first and then handles the keys that weren't consumed.SetCursorLocationgives the position (screen coordinates) for the candidate bar. The composition area is still drawn in our own candidate bar (UpdatePreeditText is not sent).- The input contexts of both XIM and IBus are
ic.h'sIC, sharing the engine state, candidate bar and shortcuts. - pomelo-session sets
QT_IM_MODULE=ibuswhen using the Pomelo input method. Qt's plugin also activates only whenibus-daemoncan be found in PATH: when no real IBus is installed, the folder of the placeholder file shipped with pomelo-input (/usr/lib/pomelo-input/qt-ibus/ibus-daemon, which does nothing) is added at the very end of PATH; "Language & Input" skips this folder when checking whether IBus is installed. - Testing: in the search box of fcitx5-config-qt (Qt5), Zhuyin "su3cl3" + Enter → 你好, and the candidate bar appears under the box.
Settings (settings.conf)
| Key | Value | Description |
|---|---|---|
input.framework |
auto / pomelo / fcitx5 / ibus / none |
with auto, pomelo-input is preferred when installed |
input.engines |
e.g. chewing,rime-pinyin,anthy |
enabled input methods and their order (follows the interface language when unset) |
input.engine |
engine id | the current input method (saved when switching, so it's the same after logging in again) |
input.kb |
KB_DEFAULT / KB_HSU / KB_ET… |
Zhuyin keyboard |
input.space_select |
0/1 | Zhuyin: Space picks a candidate |
input.shift_toggle |
0/1 | tap Shift to switch |
input.cand_per_page |
4–9 | candidates per page (Rime redeploys when changed) |
input.hangul_kb |
2 / 3f / 39 / ro |
Korean keyboard |
input.viet |
telex / vni |
Vietnamese typing method |
Limitations
- Flatpak and Snap apps can't type: they are in a sandbox, and Qt switches to the IBus portal (org.freedesktop.portal.IBus on the session bus), which we haven't implemented yet. Qt apps installed from system packages work (see "Qt apps" below).
- GTK4 apps have no XIM module; Firefox, Chrome, Electron (VS Code) and LibreOffice are all GTK3, so they're fine.
- GTK apps use "over-the-spot": the composition area is shown in our small window, not embedded directly in the app's text.
- Rocky 9 has no librime: Pinyin, Cangjie, Quick and Jyutping don't work (Japanese, Korean and Vietnamese do).
- Japanese has no predictive input and no half-width katakana (F8); Vietnamese has no automatic spell checking (switch to English when typing English words).
- Rime's user data (learned words) is separate from fcitx/ibus' Rime and isn't shared; the Zhuyin user dictionary uses libchewing's default location, the same as fcitx5-chewing.
Testing
- On Xvfb :21 with an isolated home folder: type with pomelo-edit, save, and compare the content. Zhuyin 「su3cl3」→你好, ↓ opens the candidates, then →, then Enter picks 「妳好」; Pinyin 「nihao」→你好, 「women」→我们; Cangjie 「oiar」→倉; Quick 「or」→個; Jyutping 「neihou」→你好 (with pronunciations next to the candidates); Japanese 「nihongo」→日本語, 「watashihagakuseidesu」 in two segments 「私は/学生です」, F7 「コンピューター」; Korean 「dkssudgktpdy」→안녕하세요; Vietnamese 「Tieengs Vieetj raats hay.」→Tiếng Việt rất hay.
- The Vietnamese rules are also covered by 37 unit test cases (Telex, VNI, cancelling, Backspace, uppercase).
- Settings page: move one schema's dictionary away → it shows "Download 8.4 MB" → "Downloading 37%" → "Enabled"; the downloaded files' SHA256 is correct, pomelo-input redeploys, and typing works right away.
POMELO_INPUT_DEBUG=1prints every XIM packet and key decision to stderr.