检查系统中文环境

在 Ubuntu 设置中打开「区域与语言」—— 「管理已安装的语言」,然后会自动检查已安装语言是否完整。若不完整,根据提示安装即可。

最小安装

为使用 Fcitx 5,需要安装三部分基本内容:

  1. Fcitx 5 主程序
  2. 中文输入法引擎
  3. 图形界面相关

按照这个思路,可以直接使用 apt 进行安装:

1
2
3
4
sudo apt install fcitx5 \
fcitx5-chinese-addons \
fcitx5-frontend-gtk4 fcitx5-frontend-gtk3 fcitx5-frontend-gtk2 \
fcitx5-frontend-qt5

安装中文词库

在 GitHub 打开维基百科中文拼音词库的 Releases 界面,下载最新版的 .dict 文件。按照 README 的指导,将其复制到 ~/.local/share/fcitx5/pinyin/dictionaries/ 文件夹下即可。

1
2
3
4
5
6
# 下载词库文件
wget https://github.com/felixonmars/fcitx5-pinyin-zhwiki/releases/download/0.2.4/zhwiki-20220416.dict
# 创建存储目录
mkdir -p ~/.local/share/fcitx5/pinyin/dictionaries/
# 移动词库文件至该目录
mv zhwiki-20220416.dict ~/.local/share/fcitx5/pinyin/dictionaries/**SHELL**

配置

设置为默认输入法

使用 im-config 工具可以配置首选输入法,在任意命令行输入:

1
im-config

根据弹出窗口的提示,将首选输入法设置为 Fcitx 5 即可。

环境变量

需要为桌面会话设置环境变量,即将以下配置项写入某一配置文件中:

1
2
3
export XMODIFIERS=@im=fcitx
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx

如果使用 Bash 作为 shell,则建议写入至 ~/.bash_profile,这样只对当前用户生效,而不影响其他用户。