Fixing Chinese input in WeChat on KDE Plasma Wayland with fcitx5
Contents
fcitx5 Pinyin worked fine everywhere else on my desktop, yet pressing Ctrl+Space or Shift inside WeChat did nothing at all—every keystroke stayed raw ASCII.
This was on Ubuntu 26.10 with KDE Plasma 6.7.5 (kwin-wayland / plasma-workspace 4:6.7.5-0ubuntu1) on Wayland, fcitx5 5.1.22 configured as KWin’s Virtual Keyboard in ~/.config/kwinrc, and WeChat 4.1.1.4 (/opt/wechat/wechat).
WeChat’s Linux binary statically links Qt5 with only the xcb platform plugin and an embedded fcitx-qt5 input context plugin whose key is fcitx, not fcitx5. When launched from Plasma’s desktop menu, QT_IM_MODULE wasn’t set in WeChat’s process environment, so Qt5 fell back to compose and never talked to fcitx5. Scoping QT_IM_MODULE=fcitx, GTK_IM_MODULE=fcitx, and XMODIFIERS=@im=fcitx to WeChat’s launcher fixes it without disturbing native Wayland apps. If you just want Chinese input working, jump to the fix.
Checking what fcitx5 actually sees
You can inspect every client registered with fcitx5 over D-Bus:
dbus-send --session --dest=org.fcitx.Fcitx5 --type=method_call --print-reply \
/controller org.fcitx.Fcitx.Controller1.DebugInfo
Before the fix, the output looked deceptive at first glance:
Group [wayland:] has ... InputContext(s)
IC [...] program:wechat frontend:wayland cap:d0072 focus:0
...
Group [x11::0] has 0 InputContext(s)
Group [wayland:] already showed a wechat entry, which makes it look like fcitx5 is connected. That entry only covers Wayland text-input, though—Group [x11::0] had 0 InputContext(s), meaning the XWayland/Qt5 window wasn’t talking to fcitx5 over X11 or the fcitx Qt plugin at all.
Checking the running wechat process environment explained why:
WPID=$(pgrep -x wechat | head -n 1)
tr '\0' '\n' < /proc/$WPID/environ | grep -E '^(QT_IM_MODULE|GTK_IM_MODULE|XMODIFIERS)='
# (nothing)
None of the input-method variables were present. Putting export QT_IM_MODULE=... in ~/.bashrc doesn’t reach applications started from Plasma’s launcher or systemd user units, because graphical sessions don’t source ~/.bashrc. On top of that, two common copy-paste traps in ~/.bashrc also break things when launching from a shell:
- Using
fcitx5instead offcitxforQT_IM_MODULE/GTK_IM_MODULE/XMODIFIERS. - Curly quotes or misspelled variable names pasted from blog posts (for example
XMODIFIER=’@im=fcitx5’).
Why WeChat needs QT_IM_MODULE=fcitx (not fcitx5)
Checking what /opt/wechat/wechat links against and what Qt plugins it embeds makes the requirement clear:
ldd /opt/wechat/wechat | grep -E 'xcb|wayland|X11'
# shows libX11, libX11-xcb, and libxcb-*; no libwayland-client
python3 -c '
import re
data = open("/opt/wechat/wechat", "rb").read()
for iface in (b"QPlatformIntegrationFactoryInterface", b"QPlatformInputContextFactoryInterface"):
for m in re.finditer(iface, data):
print(re.findall(b"[ -~]{3,}", data[m.start():m.start()+180]))
'
Two details stand out in the embedded QTMETADATA:
- XWayland only for Qt5: WeChat’s only
QPlatformIntegrationFactoryInterfaceplugin isQXcbIntegrationPlugin(keyxcb). It always runs its main Qt5 UI over XWayland (DISPLAY=:0), so KWin’s Waylandtext-input-v3protocol does not reach those Qt5 widgets. - Plugin key is
fcitx, notfcitx5: Its statically linkedQPlatformInputContextFactoryInterfaceplugins are:QFcitxPlatformInputContextPlugin— plugin keyfcitx(built fromfcitx-qt5)QIbusPlatformInputContextPlugin— plugin keyibusQComposePlatformInputContextPlugin— plugin keyscompose,xim
Because QT_IM_MODULE was unset, Qt5 XCB defaulted to compose. Even if QT_IM_MODULE=fcitx5 had been set, Qt5 wouldn’t find a plugin with the key fcitx5 and would still fall back to compose.
On the fcitx5 side, QT_IM_MODULE=fcitx works out of the box because fcitx5 ships both fcitx4frontend (claiming org.fcitx.Fcitx-0 on D-Bus and writing ~/.config/fcitx/dbus/<machine-id>-0) and dbusfrontend (org.freedesktop.portal.Fcitx), which WeChat’s bundled fcitx-qt5 plugin connects to directly.
Scoping the variables instead of setting them globally
On KDE Plasma 6 Wayland, KWin launches fcitx5 directly as the Wayland Virtual Keyboard ([Wayland] InputMethod[$e]=/usr/share/applications/org.fcitx.Fcitx5.desktop in ~/.config/kwinrc).
Following fcitx5’s Wayland guidance, I avoided setting QT_IM_MODULE or GTK_IM_MODULE globally in ~/.config/environment.d/. Native Wayland Qt6 and GTK applications already get input via KWin’s Wayland text-input protocol, and forcing QT_IM_MODULE=fcitx globally makes them load legacy IM modules instead.
Instead:
- Set
XMODIFIERS=@im=fcitxat the user-session level for XIM/XWayland clients. - Scope
QT_IM_MODULE=fcitxandGTK_IM_MODULE=fcitxspecifically to WeChat (includingGTK_IM_MODULE=fcitxalongsideQT_IM_MODULE=fcitxcovers itsWeChatAppExsubprocesses, which load GTK3).
The fix
1. Override the desktop launcher
Create ~/.local/share/applications/wechat.desktop. User entries in ~/.local/share/applications/ override /usr/share/applications/wechat.desktop without root permissions and survive .deb package upgrades:
[Desktop Entry]
Name=wechat
Name[zh_CN]=微信
Exec=env QT_IM_MODULE=fcitx GTK_IM_MODULE=fcitx XMODIFIERS=@im=fcitx /usr/bin/wechat %U
StartupNotify=true
Terminal=false
Icon=/usr/share/icons/hicolor/256x256/apps/wechat.png
Type=Application
Categories=Utility;
Comment=Wechat Desktop
Comment[zh_CN]=微信桌面版
Refresh the desktop database and KDE’s application cache:
update-desktop-database ~/.local/share/applications
kbuildsycoca6 --noincremental
2. Add a CLI wrapper
If you also start wechat from a terminal or script, add a wrapper earlier in $PATH at ~/.local/bin/wechat:
#!/bin/sh
export QT_IM_MODULE=fcitx
export GTK_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx
exec /usr/bin/wechat "$@"
Make it executable:
chmod +x ~/.local/bin/wechat
3. Set XMODIFIERS for the session and clean up ~/.bashrc
Create ~/.config/environment.d/im.conf with only XMODIFIERS:
XMODIFIERS=@im=fcitx
Apply it to the already-running systemd user session so you don’t have to log out:
systemctl --user set-environment XMODIFIERS=@im=fcitx
If you previously added QT_IM_MODULE, GTK_IM_MODULE, or fcitx5 exports to ~/.bashrc, remove them and keep at most export XMODIFIERS=@im=fcitx.
4. Restart WeChat
Quit the running instance and relaunch it through the new desktop entry:
pkill -TERM -x wechat
kioclient exec ~/.local/share/applications/wechat.desktop
Verifying the fix
First check that the restarted wechat process picked up the environment:
WPID=$(pgrep -x wechat | head -n 1)
tr '\0' '\n' < /proc/$WPID/environ | grep -E '^(QT_IM_MODULE|GTK_IM_MODULE|XMODIFIERS)=' | sort
# GTK_IM_MODULE=fcitx
# QT_IM_MODULE=fcitx
# XMODIFIERS=@im=fcitx
Then ask fcitx5 for its input contexts again:
dbus-send --session --dest=org.fcitx.Fcitx5 --type=method_call --print-reply \
/controller org.fcitx.Fcitx.Controller1.DebugInfo
Group [x11::0] should now list WeChat on frontend:fcitx4:
Group [x11::0] has 1 InputContext(s)
IC [...] program:wechat frontend:fcitx4 cap:800072 focus:0
At that point, clicking into a WeChat chat box and toggling Pinyin with Ctrl+Space or Left Shift pops up the candidate bar and commits Chinese text normally.
One caveat: if you enable auto-launch on login inside WeChat or add an autostart entry later, make sure the entry in ~/.config/autostart/ uses the same env QT_IM_MODULE=fcitx GTK_IM_MODULE=fcitx XMODIFIERS=@im=fcitx prefix.
Summary
- WeChat’s Linux binary embeds Qt5 XCB (
xcb) andfcitx-qt5(fcitx), so it ignores Waylandtext-inputand ignoresQT_IM_MODULE=fcitx5. - Override
~/.local/share/applications/wechat.desktop(and optionally~/.local/bin/wechat) to passQT_IM_MODULE=fcitx,GTK_IM_MODULE=fcitx, andXMODIFIERS=@im=fcitxonly to WeChat. - Restart WeChat and confirm
dbus-send ... /controller org.fcitx.Fcitx.Controller1.DebugInfoshowsprogram:wechat frontend:fcitx4underGroup [x11::0].