Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

441. Input methods

This page covers typing languages a keyboard layout alone cannot type, Chinese, Japanese and Korean among them, through fcitx5: which engines ship, how KWin starts them, the files and the settings page they are configured through, switching between them, and what to check when typing comes out as Latin. How the engine, KWin and the application are wired together is in Input methods.

Installation

Port Provides
fcitx5 The engine framework, its candidate window, fcitx5-remote, fcitx5-diagnose, and the English keyboard engine
fcitx5-chinese-addons, over libime pinyin, shuangpin and the table methods such as wbx (Wubi) and cangjie
fcitx5-anthy, over anthy-unicode anthy, for Japanese
fcitx5-hangul, over libhangul hangul, for Korean
fcitx5-qt fcitx5’s Qt 6 module, for Qt 6 programs that do not use the Wayland text-input route
fcitx5-gtk fcitx5’s GTK 3 and GTK 4 modules, which reach fcitx5 over D-Bus: the route of a GTK program under Xwayland
fcitx5-configtool System Settings → Input Method, and fcitx5-config-qt
kwin Starts fcitx5 for the session and relays it to applications over text-input
plasma-keyboard The on-screen keyboard, the other input method KWin can start

All of them are built by 50_desktop. The base the ISO carries holds the framework and its pieces, fcitx5, fcitx5-qt, fcitx5-configtool, kwin and plasma-keyboard, but no language engine: each engine comes with its language group, which also brings fcitx5-gtk and the fonts the language needs:

Group Engine Install
lang-zh fcitx5-chinese-addons sudo kdos update install lang-zh
lang-ja fcitx5-anthy sudo kdos update install lang-ja
lang-ko fcitx5-hangul sudo kdos update install lang-ko

Installing a group is in Groups. There is no service script and no autostart entry: KWin starts fcitx5 as the session’s input method and restarts it if it dies, from fs/usr/share/kdos/xdg/kwinrc:

# KWin starts fcitx5 as the session's input method and restarts it if it
# dies; nothing else starts it. The Virtual Keyboard page writes a person's
# choice of another to ~/.config/kwinrc. Its hotkeys are fcitx5/config's.
[Wayland]
InputMethod=/usr/share/applications/org.fcitx.Fcitx5.desktop

fs/usr/share/kdos/xdg/kwinrc, lines 54–58

The session wrapper clears QT_IM_MODULE and GTK_IM_MODULE, so each toolkit picks its route itself: Qt 6, GTK 3 and GTK 4 reach fcitx5 through KWin’s text-input, and a GTK program under Xwayland through fcitx5-gtk’s module over the session bus. Why each toolkit picks what it does is in Input methods.

Configuration

~/.config/fcitx5/profile

Which engines a key can reach. /etc/skel carries none: the session writes it at the first login, before KWin starts fcitx5, from the system keyboard layout in /etc/kdos/xkb.conf. It is one group, Default, whose Default Layout is the first layout of XKBLAYOUT with the first variant of XKBVARIANT after a dash (de-nodeadkeys), and whose items are keyboard-<layout>, then pinyin, anthy and hangul, the engines of the three language groups; an engine whose group is not installed is in the list but cannot be reached. With no layout in xkb.conf it takes the one locale1 serves, which follows the console keymap, and us when that names none either. A profile that exists is never rewritten. From fs/usr/local/lib/kdos/session-common.sh, which kdos-session-wrapper and the Plasma environment script both call:

# A NEW ACCOUNT'S FCITX5 PROFILE NAMES THE SYSTEM LAYOUT, NEVER A FIXED ONE.
# fcitx5, which KWin starts as the input method, takes its group's Default
# Layout as its inactive state. With its Wayland module's 'Allow Overriding
# System XKB Settings' on, it also writes that layout into ~/.config/kxkbrc as
# LayoutList, which outranks /etc/xdg/kxkbrc; /etc/xdg/fcitx5/conf/wayland.conf
# turns the option off, and the Input Method page can turn it back on. A
# profile naming any layout but the machine's would then put that layout
# under the lock screen, which checks a password typed on the wrong keys.
# So the profile is written here, before
# KWin starts, from /etc/kdos/xkb.conf (the argument replaces that path): the
# first entry of XKBLAYOUT's and of XKBVARIANT's comma lists, and when the
# layout is empty, the one locale1 serves, which follows the console keymap;
# `us` when neither names one. A value outside xkb.conf's character set
# (letters, digits, `_+:.-`) is not used. The group is the four input methods
# the image carries: the layout, then pinyin, anthy and hangul.
#
# An existing profile is never touched, so the Input Method page's choices,
# and a layout a person picked, stand. The file is written whole under a
# temporary name and renamed, so a login cut short leaves no half profile for
# the next one to keep.
kdos_session_fcitx5_profile() {
	_fx_dir=${XDG_CONFIG_HOME:-$HOME/.config}/fcitx5
	[ -n "$HOME" ] || [ -n "${XDG_CONFIG_HOME:-}" ] || return 0
	[ -e "$_fx_dir/profile" ] && { unset _fx_dir; return 0; }
	_fx_l=
	_fx_v=
	if [ -r "${1:-/etc/kdos/xkb.conf}" ]; then
		while IFS= read -r _fx_line || [ -n "$_fx_line" ]; do
			case $_fx_line in
				XKBLAYOUT=*) _fx_l=${_fx_line#XKBLAYOUT=} ;;
				XKBVARIANT=*) _fx_v=${_fx_line#XKBVARIANT=} ;;
			esac
		done < "${1:-/etc/kdos/xkb.conf}"
	fi
	if [ -z "$_fx_l" ] && command -v dbus-send >/dev/null 2>&1; then
		_fx_l=$(kdos_session_locale1 X11Layout)
		_fx_v=$(kdos_session_locale1 X11Variant)
	fi
	_fx_l=$(kdos_session_xkb_first "$_fx_l")
	_fx_v=$(kdos_session_xkb_first "$_fx_v")
	[ -n "$_fx_l" ] || { _fx_l=us; _fx_v=; }
	[ -n "$_fx_v" ] && _fx_l=$_fx_l-$_fx_v
	if mkdir -p "$_fx_dir" 2>/dev/null && printf '%s\n' \
		'[Groups/0]' '# Group Name' 'Name=Default' '# Layout' \
		"Default Layout=$_fx_l" '# Default Input Method' \
		"DefaultIM=keyboard-$_fx_l" '' \
		'[Groups/0/Items/0]' '# Name' "Name=keyboard-$_fx_l" '# Layout' 'Layout=' '' \
		'[Groups/0/Items/1]' '# Name' 'Name=pinyin' '# Layout' 'Layout=' '' \
		'[Groups/0/Items/2]' '# Name' 'Name=anthy' '# Layout' 'Layout=' '' \
		'[Groups/0/Items/3]' '# Name' 'Name=hangul' '# Layout' 'Layout=' '' \
		'[GroupOrder]' '0=Default' > "$_fx_dir/.profile.kdos.$$" 2>/dev/null; then
		mv -f "$_fx_dir/.profile.kdos.$$" "$_fx_dir/profile" 2>/dev/null || \
			rm -f "$_fx_dir/.profile.kdos.$$"
	else
		rm -f "$_fx_dir/.profile.kdos.$$" 2>/dev/null
	fi
	unset _fx_dir _fx_l _fx_v _fx_line
}

fs/usr/local/lib/kdos/session-common.sh, lines 154–211

The layout can matter beyond fcitx5: with Allow Overriding System XKB Settings on, fcitx5 writes the group’s layout into ~/.config/kxkbrc, which outranks /etc/xdg/kxkbrc (the installer’s layout, rewritten by kdos-settingsd on every locale1 layout change), so a profile naming another layout would put it under the lock screen too. KDOS ships that option off (see wayland.conf below), and a person can turn it back on from the Input Method page; the generated profile keeps the layout written then the system’s. The first item is the inactive state, plain typing in the layout; the others are what turning the input method on can reach. The Input Method page edits this file; fcitx5 writes it itself when it saves its state.

/etc/xdg/fcitx5/config

fcitx5’s global options, its hotkeys among them. fcitx5 reads one file: ~/.config/fcitx5/config when it exists, else this one. KDOS moves group switching off Meta+Space, which opens KRunner, from fs/etc/xdg/fcitx5/config:

# Group switching moves off Super+Space, which opens KRunner. KWin's global
# shortcuts are matched before a key reaches the input method, so a chord
# bound in both is never seen by fcitx5 and switching groups would stop
# without a word. Both directions move to Super+Alt, which nothing in KDE
# binds; the backward chord moves too, so the pair stays one gesture apart.
# testing/chordcheck.py fails when a chord here is also a global shortcut.
# ---------------------------------

[Hotkey/EnumerateGroupForwardKeys]
0=Super+Alt+space

[Hotkey/EnumerateGroupBackwardKeys]
0=Super+Alt+Shift+space

fs/etc/xdg/fcitx5/config, lines 16–28

Each add-on’s options are in ~/.config/fcitx5/conf/<addon>.conf, such as conf/pinyin.conf, once the Input Method page has saved them; without one, fcitx5 reads fcitx5/conf/<addon>.conf along XDG_CONFIG_DIRS.

/etc/xdg/fcitx5/conf/wayland.conf

The options of fcitx5’s Wayland module. KWin owns the keyboard layout list, so KDOS turns off Allow Overriding System XKB Settings: with it on, fcitx5 writes its group’s layout, the one in the profile above, into ~/.config/kxkbrc at every start and on every input-method change, which replaces the layout the installer, locale1 or System Settings → Keyboard set. From fs/etc/xdg/fcitx5/conf/wayland.conf:

#   fcitx5's Wayland module: KWin owns the keyboard layout list.
#
# fcitx5 reads conf/wayland.conf from ~/.config/fcitx5 if it exists, else the
# first fcitx5/conf/wayland.conf along XDG_CONFIG_DIRS (/etc/xdg when the
# variable is unset), the same lookup as fcitx5/config beside it.
#
# With the override on, its compiled default, fcitx5 writes the current
# group's layout (the profile's, which the session writes from
# /etc/kdos/xkb.conf) into ~/.config/kxkbrc as LayoutList at every start and
# on every input-method change. That replaces every layout the installer,
# locale1 or System Settings -> Keyboard set, and the lock screen then checks
# a password typed on that layout. With it off,
# fcitx5 decodes keys with the keymap KWin hands it.
# ---------------------------------

Allow Overriding System XKB Settings=False

fs/etc/xdg/fcitx5/conf/wayland.conf

With it off, the profile’s keyboard-<layout> first item is only the inactive state: fcitx5 decodes keys with the keymap KWin hands it, whatever layout that is.

/etc/xdg/fcitx5/conf/classicui.conf

The options of fcitx5’s candidate window. Its compiled default is the light default theme on every desktop; KDOS sets UseDarkTheme=True with DarkTheme=default-dark, so the window follows the portal’s colour scheme (dark under the seven dark accents, light under Paper), and UseAccentColor=True, so its highlight is the portal’s accent colour. A copy the Input Method page saves in ~/.config/fcitx5/conf/classicui.conf replaces this one whole.

The build

fcitx5 is built for Wayland only, with no X11 frontend and no autostart entry (ports/core/input/fcitx5/build.sh); every flag is explained on its package page:

cmake -S . -B build -G Ninja \
	-D CMAKE_INSTALL_PREFIX=/usr \
	-D CMAKE_INSTALL_LIBDIR=lib \
	-D CMAKE_INSTALL_SYSCONFDIR=/etc \
	-D CMAKE_BUILD_TYPE=Release \
	-D ENABLE_X11=Off \
	-D ENABLE_WAYLAND=On \
	-D ENABLE_DBUS=On \
	-D ENABLE_KEYBOARD=On \
	-D ENABLE_EMOJI=On \
	-D ENABLE_LIBUUID=On \
	-D ENABLE_SERVER=On \
	-D USE_SYSTEM_YOGA=Off \
	-D ENABLE_ENCHANT=On \
	-D ENABLE_DOC=Off \
	-D ENABLE_TEST=Off \
	-D ENABLE_TESTING_ADDONS=On \
	-D ENABLE_XDGAUTOSTART=Off \
	-D BUILD_SPELL_DICT=On \
	-D USE_SYSTEMD=Off \
	-D EVENT_LOOP_BACKEND=libuv \
	-D USE_SYSTEM_PLASMA_WAYLAND_PROTOCOLS=On \
	-Wno-dev

ports/core/input/fcitx5/build.sh, lines 15–37

The GTK modules are built for GTK 3 and GTK 4 alone, and the build writes the list GTK 3 loads a module through, /usr/lib/gtk-3.0/3.0.0/immodules.cache, because GTK 3 ignores a module that list does not name (ports/core/input/fcitx5-gtk/build.sh; the reasons are on its package page):

cmake -S . -B build -G Ninja \
	-D CMAKE_INSTALL_PREFIX=/usr \
	-D CMAKE_INSTALL_LIBDIR=lib \
	-D CMAKE_BUILD_TYPE=Release \
	-D ENABLE_GTK2_IM_MODULE=OFF \
	-D ENABLE_GTK3_IM_MODULE=ON \
	-D ENABLE_GTK4_IM_MODULE=ON \
	-D ENABLE_GIR=OFF \
	-D FCITX5_GTK_VERSION=$version \
	-Wno-dev
cmake --build build
DESTDIR=$PKG cmake --install build

immod=/usr/lib/gtk-3.0/3.0.0
cache=$(LD_LIBRARY_PATH="$PKG/usr/lib" gtk-query-immodules-3.0 "$PKG$immod/immodules/im-fcitx5.so")
grep -q '"fcitx5"' <<<"$cache"
printf '%s\n' "${cache//"$PKG"/}" > "$PKG$immod/immodules.cache"

ports/core/input/fcitx5-gtk/build.sh, lines 14–30

The Chinese engines are built without cloud pinyin, which would send what you type to a remote service:

	-D ENABLE_GUI=Off \
	-D ENABLE_BROWSER=Off \
	-D ENABLE_CLOUDPINYIN=Off \

ports/core/input/fcitx5-chinese-addons/build.sh, lines 20–22

Inside a box

A boxed application reaches fcitx5 through KWin, never directly. kdos-appbox sets one variable for it (src/system/kdos-appbox/main.c):

	 * Input methods. A boxed app reaches fcitx5 through the COMPOSITOR —
	 * text-input to KWin, which relays to the input method KWin itself
	 * started — and never directly, because fcitx5 runs on the host and its
	 * bus name is not one the box's proxy passes.
	 *
	 * So the value is `wayland` and emphatically not `fcitx`: the fcitx
	 * module is the X11-era route where each toolkit talks to the IM daemon
	 * itself, and inside a container that daemon is not there. GTK on
	 * Wayland picks the right context on its own when GTK_IM_MODULE is
	 * UNSET, which is why only Qt is named here — setting GTK_IM_MODULE at
	 * all is how a working GTK app stops accepting CJK input.
	 */
	kb_argv_add(a, "QT_IM_MODULE=wayland");

src/system/kdos-appbox/main.c, lines 526–538

Usage

Typing in another language

  1. Install the language’s group, if you have not: sudo kdos update install lang-zh (or lang-ja, lang-ko), then log out and in again so fcitx5 loads the new engine.
  2. Click into a text field of an application, host or boxed.
  3. Press Ctrl+Space to turn the input method on. fcitx5 switches from the layout item (keyboard-de on a German machine) to the engine used last; the first time, that is the first installed engine after it in the profile (pinyin, then anthy, then hangul).
  4. Type. The text being composed is shown in the field, and the numbered candidates appear in fcitx5’s candidate window beside it; choose a candidate with its number key.
  5. Press Ctrl+Space again to go back to plain typing.

To reach another engine, press Ctrl+Space and keep Ctrl held: the second Space turns the input method off again, and each Space after it steps to the next engine in the group. While an engine is on, the left Shift on its own switches to plain typing and back. The input method’s tray icon shows which engine is in use.

Adding an engine

  1. System Settings → Input Method.
  2. Add Input Method. The list opens with Only Show Current Language ticked, and the session’s language is always English, so it holds only English keyboard layouts: untick it, or type the engine’s name in the list’s Search… field. Pick the engine, for example Shuangpin, Wubi or Anthy, and Add.
  3. Apply. fcitx5 reloads, and the engine is in the group at once.

The same page sets the hotkeys and, through each engine’s configure button, its options.

The language’s glyph forms

Each language group carries noto-cjk and a default that makes that language’s variant of it the first CJK face: noto-cjk-prefer-ja in lang-ja (Noto Sans CJK JP), noto-cjk-prefer-zh in lang-zh (SC, Simplified Chinese) and noto-cjk-prefer-ko in lang-ko (KR). The session runs in en_US.UTF-8, so the text typed here names no language, and the default decides whether a kanji takes its Japanese or its Korean or Chinese shape. With two groups installed, the lower file name wins, ja before ko before zh; how fontconfig orders them is in Han text and the language groups.

Switching engine from a prompt

fcitx5-remote -n             # the engine in use
fcitx5-remote -s anthy       # switch to anthy
fcitx5-remote -s keyboard-de # back to the layout, on a German machine
fcitx5-remote                # 1 inactive, 2 active, 0 no text field has the focus

Each of these acts on the text field that has the focus, so run them in Konsole, which is itself such a field. An engine that is not in the profile’s group cannot be switched to. fcitx5-remote --check exits with status 1 and starts nothing when fcitx5 is not running.

The on-screen keyboard

System Settings → Keyboard → Virtual Keyboard chooses between fcitx5 and Plasma Keyboard; only one input method runs at a time. See Accessibility.

The live medium and an installed system

The engines and the profile are the same on both. On the live medium the home directory is in memory, so a changed profile lasts until power-off unless a persistence store exists (kdos persist).

Tips

Troubleshooting

Ctrl+Space does nothing and every key arrives as Latin.

  1. pgrep -a fcitx5. No line means fcitx5 is not running: check that Fcitx 5 is chosen on the Virtual Keyboard page, and grep -A1 Wayland ~/.config/kwinrc for an InputMethod of your own that names something else.
  2. fcitx5-remote -n while the field has the focus. The layout item, such as keyboard-us, after Ctrl+Space means no engine is installed: the input method profile names pinyin, anthy and hangul, but each comes only with its language group. kdos update groups shows which groups are installed; install the one you need with sudo kdos update install lang-zh (or lang-ja, lang-ko), then log out and back in.
  3. Check the application in another program: if it works in another GTK or Qt program and not in this one, the toolkit is the cause.

A GTK application takes no input method although others do. Something in its environment sets GTK_IM_MODULE, a wrapper script or a profile of your own. Unset it there. On Wayland, gtk-query-settings | grep im-module must print wayland for GTK 3 and gtk4-query-settings | grep im-module an empty string for GTK 4; GTK 4 prints simple, plain typing, when no portal backend answers org.gnome.desktop.interface, which xdg-desktop-portal-gtk serves. GTK 3 reads the same portal under GTK_USE_PORTAL=1 and still prints wayland: it sets that value itself whenever KWin offers text-input-v3, above the portal’s empty one. Under Xwayland, grep fcitx5 /usr/lib/gtk-3.0/3.0.0/immodules.cache must print the module’s lines: without them GTK 3 never loads fcitx5-gtk’s module and falls back to plain typing. fcitx5-gtk comes with a language group, so with no group installed the cache has no fcitx5 lines and a GTK program under Xwayland has no input method.

The keyboard layout goes back to another one at every login. grep -E 'LayoutList|Use' ~/.config/kxkbrc printing a LayoutList you did not choose means something wrote it for you. grep -r 'XKB Settings' ~/.config/fcitx5/conf/wayland.conf /etc/xdg/fcitx5/conf/wayland.conf must print False; a True of your own, saved from the Input Method page, lets fcitx5 write its group’s layout into kxkbrc again, and grep 'Default Layout' ~/.config/fcitx5/profile names the layout it writes. Then set the layout on System Settings → Keyboard, or delete ~/.config/kxkbrc and log in again to take the system’s.

Running fcitx5 in the foreground for its messages. fcitx5-diagnose prints upstream’s report of the environment. KWin restarts fcitx5 when it exits; its messages go to the session log, ~/.local/share/sddm/wayland-session.log.

Known gaps

See also