Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integration: add input method section #49

Merged
merged 9 commits into from
Mar 25, 2024
79 changes: 79 additions & 0 deletions src/integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
7. [Session Lock](#session-lock)
8. [Desktops](#desktops)
9. [Qt](#qt)
10. [Input Method](#input-method)

# 1. Introduction {#introduction}

Expand Down Expand Up @@ -328,6 +329,84 @@ and set `QT_QPA_PLATFORMTHEME=qt6ct` in `~/.config/labwc/environment`.

[qt6-wayland]: https://archlinux.org/packages/extra/x86_64/qt6-wayland/
[qt6ct]: https://github.com/trialuser02/qt6ct

# 10. Input Method {#input-method}

Input methods like Fcitx5 and IBus provide modules for GTK and Qt and an
interface for xserver (xwayland) using D-Bus without wayland protocols.

You can enable input method for those platforms by setting environment
variables like this:

```
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx
```

<!-- TODO: remove "in the master branch" when labwc 0.7.2 is released -->
For apps not running on those platforms (e.g. Alacritty), labwc supports
the following wayland protocols in the master branch:

- [text-input-v3]
- Used by winit apps (e.g. Alacritty) and GTK (without setting
`GTK_IM_MODULE` environment variable).
- [input-method-v2]
- Supported by Fcitx5, but not by IBus yet ([issue]).

Here is a quick guide for using Fcitx5 in labwc:

1. Install fcitx5, GTK/Qt modules, configtool and language-specific module.
- Arch Linux: `pacman -S fcitx5-im fcitx5-mozc`
- Ubuntu: `apt install fcitx5 fcitx5-mozc`

Replace `fcitx5-mozc` with a module for your language.

2. Set `GTK_IM_MODULE`, `QT_IM_MODULE` and `XMODIFIERS` like described earlier.
These are usually saved in files like `~/.profile`, `~/.bash_profile` and
`/etc/environment`.
Consolatis marked this conversation as resolved.
Show resolved Hide resolved

3. Start `fcitx5`. You can automatically start fcitx5 by adding `fcitx5 &` to
`~/.config/labwc/autostart`.

4. Configure Fcitx5 with configtool to enable the installed language-specific
module and to set up hotkeys. See [Configtool (Fcitx 5) - Fcitx].

5. Activate input method with hotkeys while typing in applications.

<!--- TODO: remove this once https://chromium-review.googlesource.com/c/chromium/src/+/3750452 is merged -->
## Input method on Chromium

Chromium (and Electron-based apps) currently doesn't support [text-input-v3]
Consolatis marked this conversation as resolved.
Show resolved Hide resolved
protocol. So if you want to use IME with Chromium under labwc, you have
following options:

1. Run Chromium under XWayland

This is the default option. However, some features like touchpad gesture
don't work.

2. Use GTK IM Module

By running Chromium with `--enable-features=UseOzonePlatform --ozone-platform=wayland --gtk-version=4`,
you can enable IME with GTK IM Module (selected by `GTK_IM_MODULE`) under
wayland. However, IME popups might be incorrectly positioned.

3. Patch labwc and use [text-input-v1] protocol

Since [text-input-v1] is an outdated protocol, labwc doesn't officially
support it. However, you can optionally add support for it by installing
labwc from the unofficial [AUR] or by applying its patch. Then, you can
enable IME with [text-input-v1] by running Chromium with
`--enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime`.

[text-input-v3]: https://wayland.app/protocols/text-input-unstable-v3
[input-method-v2]: https://wayland.app/protocols/input-method-unstable-v2
[issue]: https://github.com/ibus/ibus/issues/2182
[Configtool (Fcitx 5) - Fcitx]: https://fcitx-im.org/wiki/Configtool_(Fcitx_5)
[text-input-v1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/main/unstable/text-input/text-input-unstable-v1.xml
[AUR]: https://aur.archlinux.org/packages/labwc-im

[waybar repository]: https://github.com/Alexays/Waybar
[waybar documentation]: https://github.com/Alexays/Waybar/tree/master/man
[xfce4-panel repository]: https://gitlab.xfce.org/xfce/xfce4-panel
Expand Down