概要
以前、fcitx-mozc を使用していたのですが、IMが切り替わらなくなることがあり、emacs-mozc を使用していました。 あらためて今回調査したところ、fcitx5-mozc を使えば、比較的安定して動作することがわかりました。(ただし、やはり不安定な部分はあります)
ibus-mozc, emacs-mozc のアンインストール
他のIMをインストールしていた場合はアンインストールします。
$ sudo apt list --installed | grep mozc
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
emacs-mozc-bin/jammy,now 2.26.4220.100+dfsg-5.2 amd64 [installed,automatic]
emacs-mozc/jammy,now 2.26.4220.100+dfsg-5.2 amd64 [installed]
ibus-mozc/jammy,now 2.26.4220.100+dfsg-5.2 amd64 [installed]
mozc-data/jammy,jammy,now 2.26.4220.100+dfsg-5.2 all [installed]
mozc-server/jammy,now 2.26.4220.100+dfsg-5.2 amd64 [installed]
$ sudo apt remove ibus-mozc $ sudo apt remove emacs-mozc
詳細
fcitx5-mozc をインストールします。
sudo apt install fcitx5-mozc
.bashrc に下記を追記します。
export GTK_IM_MODULE=fcitx5 export QT_IM_MODULE=fcitx5 export XMODIFIERS=@im=fcitx5 export INPUT_METHOD=fcitx5 export DefaultIMModule=fcitx5 if [ $SHLVL = 1 ] ; then (fcitx5 --disable=wayland -d --verbose '*'=0 &) fi
bashを再起動します。
キー設定
fcitx5-configtool の起動
fcitx5-configtool
初期状態では下記のようになっています。
右側の入力部分でmozcを検索します。
mozcを選択し、「←」の部分をクリックして左側の枠に表示されるようにします。
左側に表示されました。 「↑」をクリックして一番上に移動します。
Applyします。
Applyされた状態。
IM切替時のMethod informationの表示を無効化
EmacsでIM切り替え時に表示がパタパタしてしまうのでこちらは非表示にします。
デフォルトではチェックが入っています。
チェックを外します。
Ctrl + Space の無効化
デフォルトの設定ではこのようになっています。
削除します。
削除後の状態です。
Control + ; の無効化
Addons -> Module -> Clipboard のところにあります。
設定を開きます。
削除します。
.emacs.d/init.el の設定
;;---- fcitx5 ---- ; you need to install "fcitx5-mozc" first (defun my-fcitx5-set-english () "Switch fcitx5 to English mode (input off) at Emacs startup." (shell-command "fcitx5-remote -o")) (add-hook 'after-init-hook #'my-fcitx5-set-english) (defun my-fcitx5-indicator () "Function to return a string indicating the status of fcitx5." (let ((state (string-trim (shell-command-to-string "fcitx5-remote")))) (if (string= state "2") "[A]" "[あ]"))) (setq-default mode-line-format (cons '(:eval (my-fcitx5-indicator)) mode-line-format))
Ubuntu nativeでの設定
上記は、WSLで行った内容ですが、Ubuntu native環境だと他にも設定を行う必要があることに気づきました。
まず、im-config を fcitx5に設定します。
引数なしでim-configを実行すると下記のように表示されていました。
sudo im-config
fcitx5を指定します。
im-config -n fcitx5
キーボードが “Keyboard – English(US)” となっているので、私の環境で使用している “Keyboard – Japanese” を追加します。
“Your currently configured input method does not match your layout”と言われるのですが、Yesとしました。
なお、frontend が入っていないとアプリケーションによって日本語入力ができない、というような状況になりえます。 不足していればインストールします。 私の環境ではfcitx関連で下記がインストールされており、問題ないようでした。
$ sudo apt list --installed | grep fcitx
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
fcitx-mozc-data/jammy,jammy,now 2.26.4220.100+dfsg-5.2 all [installed,automatic]
fcitx5-config-qt/jammy,now 5.0.11-1 amd64 [installed,automatic]
fcitx5-data/jammy,jammy,now 5.0.14-1 all [installed,automatic]
fcitx5-frontend-gtk3/jammy,now 5.0.12-1 amd64 [installed,automatic]
fcitx5-frontend-gtk4/jammy,now 5.0.12-1 amd64 [installed,automatic]
fcitx5-frontend-qt5/jammy,now 5.0.10-1build1 amd64 [installed,automatic]
fcitx5-module-emoji/jammy,now 5.0.14-1 amd64 [installed,automatic]
fcitx5-module-quickphrase/jammy,now 5.0.14-1 amd64 [installed,automatic]
fcitx5-module-wayland/jammy,now 5.0.14-1 amd64 [installed,automatic]
fcitx5-module-xorg/jammy,now 5.0.14-1 amd64 [installed,automatic]
fcitx5-modules/jammy,now 5.0.14-1 amd64 [installed,automatic]
fcitx5-mozc/jammy,now 2.26.4220.100+dfsg-5.2 amd64 [installed]
fcitx5/jammy,now 5.0.14-1 amd64 [installed,automatic]
libfcitx5-qt-data/jammy,jammy,now 5.0.10-1build1 all [installed,automatic]
libfcitx5-qt1/jammy,now 5.0.10-1build1 amd64 [installed,automatic]
libfcitx5config6/jammy,now 5.0.14-1 amd64 [installed,automatic]
libfcitx5core7/jammy,now 5.0.14-1 amd64 [installed,automatic]
libfcitx5gclient2/jammy,now 5.0.12-1 amd64 [installed,automatic]
libfcitx5utils2/jammy,now 5.0.14-1 amd64 [installed,automatic]