5

Pop!_OS 22.04 安装配置 Fcitx5 与「中州韵」

 9 months ago
source link: https://jixun.uk/posts/2023/popos-2204-fcitx5/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Pop!_OS 22.04 安装配置 Fcitx5 与「中州韵」

Fcitx 是一个适用于 Linux 平台下的输入法框架,而「中州韵」则是一个中文输入法;二者搭配即可实现 Linux 系统下的中文输入。

之前在 Pop!_OS 21.04 的时候试过旧版 fcitx,这次被 Wayland 坑得难受,换回 Pop!_OS 了。

安装本体 #

正常安装一些包。其中 fcitx5-rime 是「中州韵」中文输入,而 fcitx5-mozc 则是日文输入。根据需求选择安装。

sudo apt update
sudo apt install fcitx5 \
  fcitx5-chinese-addons \
  fcitx5-material-color \
  fcitx5-{rime,mozc} \
  fcitx5-table-emoji fcitx5-module-emoji \
  fcitx5-config-qt fcitx5-frontend-{gtk3,gtk4,qt5}

然后还原 Pop!_OS 自作主张添加的环境变量

sudo tee /etc/profile.d/z-pop-os-fcitx.sh <<'EOF'
export GTK_IM_MODULE=""
export QT_IM_MODULE=""
export XMODIFIERS=""
EOF

最后将 fcitx5 设置为「当前用户」的默认输入法:

# 注意不需要 root 权限执行
im-config -n fcitx5

随后重启进入系统即可启用 fcitx5

添加「中州韵」输入法 #

重启后可以发现右上角多了一个「⌨ 键盘」图标。点击它,然后选择「配置(Configure)」:

popos-2204-fcitx5

Fcitx 5 的配置菜单入口

然后依次添加输入法即可:

  1. 右侧输入框检索「Rime」
  2. 选中并按下「<」添加到当前输入法组
  3. 单击「应用(Apply)」储存设定
popos-2204-fcitx5

Fcitx 5 的配置界面,添加 Rime 输入法

使用「Super - 空格」切换输入法 #

※ Super 键在一些键盘中的标注是「⊞ Win」。

  1. 打开 Fcitx 5 的配置界面;
  2. 切换到「全局设定(Global Options)」标签页;
  3. 按下第一项的「切换输入法(Trigger Input Method:)」右侧的 Control + Space 默认按键配置按钮;
  4. 等待按钮提示「… …」后按下「Super - 空格」组合键确认;
  5. 单击「应用(Apply)」储存设定。

因为默认情况下 ibus 的输入法切换键也是 Super + Space,因此需要禁用它:

# 禁用 ibus 输入法切换键
gsettings set org.gnome.desktop.wm.keybindings switch-input-source '[]'
gsettings set org.gnome.desktop.wm.keybindings switch-input-source-backward '[]'

当然,如果需要恢复默认的 ibus 输入法切换键,执行下述指令即可还原:

# 还原 ibus 输入法切换键
gsettings reset org.gnome.desktop.wm.keybindings switch-input-source
gsettings reset org.gnome.desktop.wm.keybindings switch-input-source-backward

修正「中州韵」无法启动 #

第一次进入切换到「中州韵」输入法时可能会无法正常使用,并提示查看错误文件。

该文件的内容如下:

$ grep error cat /tmp/rime.fcitx-rime.ERROR
E0916 00:48:52.863051  8738 deployment_tasks.cc:270] error creating directory '/home/jixun.uk/.local/share/fcitx5/rime/build'.

不知为何未能建立缓存目录,因此手动建立下:

mkdir -p "$HOME/.local/share/fcitx5/rime/build"

然后点击屏幕右上角的「⌨ 键盘」菜单→选择「重新启动(Restart)」即可。

维基百科词库 #

根据 AUR 仓库的 fcitx5-pinyin-zhwiki 构建脚本 重写;使用请遵守其使用协议1

# 抓取版本信息
RIME_ZHWIKI_METADATA="$(
  curl -fsL https://gitlab.archlinux.org/archlinux/packaging/packages/fcitx5-pinyin-zhwiki/-/raw/main/PKGBUILD \
    | gawk '/^(_converterver|_webslangver)/'
)"
get_meta() {
  echo -n "${RIME_ZHWIKI_METADATA}" \
    | grep "^${1}=" \
    | cut -d= -f2 \
    | head -n 1
}
release="$(get_meta _converterver)"
dict_ver="$(get_meta _webslangver)"

# 准备写入,然后写入
mkdir -p "$HOME/.local/share/fcitx5/pinyin/dictionaries/"
curl -fsL -o"$HOME/.local/share/fcitx5/pinyin/dictionaries/zhwiki.dict" \
  "https://github.com/felixonmars/fcitx5-pinyin-zhwiki/releases/download/${release}/zhwiki-${dict_ver}.dict"

为确保加载成功,手动重启一下 Fcitx 5 服务即可。


  1. 词库授权同维基百科授权协议,使用 GFDLCC-ASA 3.0 协议;详细信息请参考官方说明。 ↩︎


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK