fcitx5 on SwayWM

by Maurice Zhou, posted in Linux

fcitx5 is a fairly new input method on GNU/Linux platform. You will need a recent system version to have the full set of packages available in the official repository. I’m using Debian bulleye (testing) here. Also tested on ArchLinux.

Due to the broken nature1 of Wayland input method support, every IME, fcitx5 included, requires xwayland to run properly.

Note: there’s no need to configure SwayWM for different keyboard layouts, fcitx5 will handle this.

Installation

fcitx5 base

apt install --yes fcitx5 fcitx5-frontend-gtk3 fcitx5-frontend-qt5 fcitx5-module-dbus fcitx5-module-wayland fcitx5-module-xorg fcitx5-config-qt

fcitx5 pinyin

apt install --yes fcitx5-pinyin

Environment variables

if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then   # Launch SwayWM on tty1
  if  [ ! -d "$HOME/Pictures/Screenshots" ];             # Create Screenshots folder for grim
    then mkdir -p $HOME/Pictures/Screenshots;
  fi
  export GRIM_DEFAULT_DIR=$HOME/Pictures/Screenshots
  eval `ssh-agent`                                       # ssh-agent for use with KeePassXC
  # ---- the useful line ----
  export GTK_IM_MODULE=fcitx && export QT_IM_MODULE=fcitx && export XMODIFIERS=@im=fcitx
  # -------------------------
  export MOZ_ENABLE_WAYLAND=1                            # Wayland for Firefox-ESR and Thunderbird
  export QT_QPA_PLATFORM=wayland                         # Wayland for Qt5
  export QT_QPA_PLATFORMTHEME=qt5ct                      # Qt5 theme
  exec sway                                              # Start SwayWM
fi

Start fcitx5 when starting SwayWM

exec fcitx5 -rd &

Configuration

Run fcitx5-configtool. Add the desired language and keyboard layouts. Uncheck Only show current language to list all options available.

中文

fcitx5 是GNU/Linux平台上的一个新输入法。因为比较新,只有新版本的系统里有所需要的全部软件包。这里我使用了Debian bulleye (testing)。实测ArchLinux也可以。

因为Wayland对输入法的支持不完善1,包括fcitx5在内的所有输入法都依赖xwayland运行。

提示:如果需要其他键盘布局的话(比如德语键盘)没必要配置SwayWM。在fcitx5中就可以切换。

安装

fcitx5 框架

apt install --yes fcitx5 fcitx5-frontend-gtk3 fcitx5-frontend-qt5 fcitx5-module-dbus fcitx5-module-wayland fcitx5-module-xorg fcitx5-config-qt

fcitx5 拼音

apt install --yes fcitx5-pinyin

环境变量

if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then   # 在tty1登陆时启动SwayWM 
  if  [ ! -d "$HOME/Pictures/Screenshots" ];             # 为grim创建截图文件夹
    then mkdir -p $HOME/Pictures/Screenshots;
  fi
  export GRIM_DEFAULT_DIR=$HOME/Pictures/Screenshots
  eval `ssh-agent`                                       # 用于KeePassXC的ssh-agent
  # ---- 这行与fcitx有关 ----
  export GTK_IM_MODULE=fcitx && export QT_IM_MODULE=fcitx && export XMODIFIERS=@im=fcitx
  # -------------------------
  export MOZ_ENABLE_WAYLAND=1                            # Wayland for Firefox-ESR and Thunderbird
  export QT_QPA_PLATFORM=wayland                         # Wayland for Qt5
  export QT_QPA_PLATFORMTHEME=qt5ct                      # Qt5 主题
  exec sway                                              # 启动SwayWM
fi

启动SwayWM时,启动fcitx5

exec fcitx5 -rd &

配置

运行fcitx5-configtool。添加想要的键盘布局和语言。取消勾选Only show current language以显示全部语言。


  1. Comments from the author of fcitx5 ↩︎

edited: