sway窗口管理器使用fcitx5

树莓派安装Kali Linux ,使用体验发现默认的 xfce 对于ARM架构的 树莓派Raspberry Pi 400 还是过于沉重,所以尝试切换到基于 wayland显示服务器协议sway - i3兼容Wayland compositor ,实践下来体验非常接近完美(资源占用极小)。

sway - i3兼容Wayland compositor 使用非常现代化的 wayland显示服务器协议 显示服务,这要求应用软件进行适配,所以也带来很多不兼容的问题。根据网上资料, 小企鹅输入法fcitx 已经支持 sway ,并且根据我以往经验,fcitx配置也较为简便,兼容性不错,性能也比较好。所以,我经过一些尝试,成功在 sway - i3兼容Wayland compositor 环境使用 小企鹅输入法fcitx 进行中文输入和日常工作。

安装和配置

  • Kali Linux 基于debian,软件非常丰富且安装简便:

    sudo apt install fcitx5 fcitx5-chinese-addons
    
  • 启用fcitx的输入需要配置环境变量,标准方式是修改 /etc/environment (通用于各种 Shell Atlas ),添加以下配置

启用fcitx5环境变量配置 /etc/environment
GTK_IM_MODULE=fcitx
QT_IM_MODULE=fcitx
XMODIFIERS=@im=fcitx
INPUT_METHOD=fcitx
SDL_IM_MODULE=fcitx
GLFW_IM_MODULE=ibus
复制sway个人配置
mkdir -p ~/.config/sway
cp /etc/sway/config ~/.config/sway/

备注

sway 的全局配置文件 /etc/sway/config.d/50-systemd-user.conf 从系统用户环境导入变量,执行了以下两条命令:

exec systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK

exec hash dbus-update-activation-environment 2>/dev/null && \
        dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK
  • 在个人配置定制文件 ~/.config/sway/config 中添加一行:

在 ~/.config/sway/config 中添加运行 fcitx5 的配置
#以下两种方法可能都行
#exec_always fcitx5 -d --replace
exec_always --no-startup-id  fcitx5 -d
  • 重启系统,这样环境变量和sway配置都生效,登陆到 sway 系统中,就会看到右上角有一个 fcitx 运行图标

  • 执行 fcitx5-configtool 进行配置,注意,在sway环境,这个配置工具依赖 QT 运行,但是默认由于没有安装插件,会出现报错信息如下:

    qt.qpa.plugin: Could not find the Qt platform plugin "wayland" in ""
    qt.qpa.xcb: could not connect to display
    qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
    This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
    
    Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.
    
    zsh: abort      fcitx5-configtool
    

解决方法通过观察上文报错可以得知,缺少 wayland 插件和 xcb 插件支持。所以对应安装:

sudo apt install qtwayland5 qt5dxcb-plugin

再次运行 fcitx5-configtool 就能正常配置。

其他待解决问题

参考