Skip to content

Autocomplete on KDE Plasma through KWin's input method - #462

Merged
stevyhacker merged 1 commit into
masterfrom
claude/kde-autocomplete
Nov 9, 2026
Merged

stevyhacker merged 1 commit into
masterfrom
claude/kde-autocomplete

Conversation

@stevyhacker

Copy link
Copy Markdown
Owner

Summary

Autocomplete in other apps now works on KDE Plasma (Wayland), the one major Linux desktop where it only worked in the practice editor.

KWin talks zwp_input_method_v1 only to the program it starts itself, the one chosen under System Settings → Keyboard → Virtual Keyboard, and starts it again only when it crashes. So a small helper, lokalbot --kwin-input-method, holds that connection for the whole session and passes the field to the app over a socket in LokalBot's private runtime folder (owner-only, peer uid checked). The app runs the shared Core as the Sway and GNOME routes do. Quitting and reopening LokalBot leaves the input method in place; with the app closed the helper takes no keys, shows nothing and holds no text.

  • input_method/kwin_helper.rs: the helper. Grabs the keyboard only while a suggestion shows; every key but the accept keys and Esc goes straight back to KWin.
  • input_method/kwin.rs: the app's route, Settings steps, and the desktop entry.
  • input_method/kwin_wire.rs: the line-based JSON messages, with a version handshake (after an update, Settings asks for one log-out until Plasma starts the new helper).
  • The front window on KDE is named by the existing KWin script probe (now in FrontWindows::connect), so excluded apps are refused before their text is used.
  • com.lokalbot.LokalBot.InputMethod.desktop (X-KDE-Wayland-VirtualKeyboard=true, NoDisplay=true) is installed by the .deb/.rpm/Arch packages, install.sh and the AUR PKGBUILD. A copy run from the extracted folder gets a one-line command in Settings (lokalbot --kwin-input-method-entry).
  • 4 new Settings strings and 1 updated one, in all 24 languages. PRIVACY.md (effective date bumped) and the port README describe the route and what was run.

Design details that came from KWin 6.8 itself rather than its docs: a move to another field or window arrives as deactivate + activate, reset comes after enable, and the content type is re-sent on most GTK 3 keystrokes, so only activate, deactivate and reset mark a new field. With no keyboard grab KWin commits the preedit's commit text on the next key, so the suggestion's commit text is always empty.

Validation

On the Ubuntu box (Linux CI's commands, final code):

cargo fmt --all -- --check                                   # exit 0
python3 -m unittest discover -s scripts/tests                # OK
python3 scripts/sync-localizations.py --check                # OK
cargo clippy --workspace --all-targets --locked -- -D warnings   # exit 0
cargo test --workspace --locked                              # 2328 passed, 0 failed
cargo build --locked -p lokalbot-app                         # exit 0

10 new unit tests (wire framing and limits, content-type mapping, socket replacement and permissions, peer check, desktop entry and its quoting, packaged entry matches the generated one).

Live, under headless KWin 6.8.2 (Arch, Plasma 6) with keys typed through KWin's EIS endpoint (crates/lokalbot-platform/scripts/live-kwin.sh, new ignored test kwin_input_method_shows_accepts_and_stays_out_of_passwords), passing:

  • GTK 3: typing reaches the field; the suggestion shows inline; Tab is taken and the accept commits with the rest still showing; other keys pass and the suggestion steps aside; delete-and-replace; the full-accept key and Esc are taken; the keyboard is released after; a password field is refused and never read; an excluded app (named by KWin) is refused; quitting the app with a suggestion on show clears it and typing carries on.

The live test passed 3 of 3 runs with KWin starting the real app binary (lokalbot --kwin-input-method) as its input method, and also with the helper example.

Probes with a stand-in app driving the helper: GTK 4, Qt 6 and Qt 5 each show the suggestion, take Tab and commit it. install.sh installs the entry with the absolute Exec and --uninstall removes it.

Not run: Firefox and Chrome on KDE (Firefox's content sandbox won't start in the test container), a real Plasma desktop with a real model, Plasma 5. The Sway live test wasn't rerun; wlroots.rs only had items made visible to the new route.

Changed test expectations

None.

Risk / rollout notes

  • New process: Plasma runs lokalbot --kwin-input-method for the session once the user picks LokalBot under Virtual Keyboard. It exits only when KWin closes the connection; a crash makes KWin restart it (KWin gives up after 5 in 20 s).
  • Choosing LokalBot there replaces Fcitx or IBus as Plasma's input method; Settings and the README say so.
  • The website (Linux guide and FAQ, the alpha blog post, llms.txt, the privacy page, the Wayland autocomplete explainer) still says KDE isn't supported. Update it when the release ships, not before.

KWin talks zwp_input_method_v1 only to a program it starts itself, the one
chosen under System Settings → Keyboard → Virtual Keyboard, and starts it again
only if it crashes. So `lokalbot --kwin-input-method` holds that connection for
the session and passes the field to the app over a socket in LokalBot's
private runtime folder; the app runs the shared Core as on the other routes.
Quitting and reopening LokalBot leaves the input method in place, and with the
app closed the helper takes no keys and shows nothing.

- New route (kwin.rs), helper (kwin_helper.rs) and their messages
  (kwin_wire.rs). The keyboard is grabbed only while a suggestion shows.
- KWin names the window in front through the existing KWin script probe, so
  excluded apps are refused before their text is used.
- A desktop entry lists LokalBot under Virtual Keyboard; packages, install.sh
  and the AUR package install it, and Settings shows a command otherwise.
- Settings strings in all 24 languages; PRIVACY.md and the port README.
- Live test under headless KWin, typing through KWin's EIS endpoint
  (scripts/live-kwin.sh).
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
lokalbot 24088a5 Commit Preview URL

Branch Preview URL
Nov 09 2026, 04:49 AM

@stevyhacker
stevyhacker marked this pull request as ready for review November 9, 2026 04:51
@stevyhacker
stevyhacker merged commit 71045df into master Nov 9, 2026
37 of 38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant