1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ラズパイOSで日本語入力の設定

1
Posted at

はじめに

 いつもラズパイの日本語入力方法が忘れてしまうので、メモしておきます。

やること

 方法1、2を下記しますが、方法1を推奨します。

方法1: fcitx5 + Mozc の再設定

1. パッケージのインストール

sudo apt update
sudo apt install -y fcitx5 fcitx5-mozc

2. 環境変数の設定

~/.profile または ~/.bashrc に以下を追加します:
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx

ターミナルで一発で書き込む場合:

cat >> ~/.profile << 'EOF'
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx
EOF

3. fcitx5 の自動起動設定

mkdir -p ~/.config/autostart
cp /usr/share/applications/org.fcitx.Fcitx5.desktop ~/.config/autostart/

4. 再起動後、Mozc を入力メソッドに追加

# GUIで設定を開く
fcitx5-configtool

「入力メソッド」タブで Current Input Method 欄に Mozc があることを確認します。
なければ、右隣の Available Input Method 欄にある Mozc を選択して <-(左向き矢印)ボタンをクリックすると、左欄に入ります。

画面上のタスクバーで、ja か en を右クリックして、Keyboard-Japanese, Keyboard-English(US)の下にMozcがあれば OK です。日本語入力に切り替えるときは、CtrL + space key です。

方法2: ibus + Mozc の場合

1. インストール

sudo apt install -y ibus ibus-mozc

2. 環境変数の設定

cat >> ~/.profile << 'EOF'
export GTK_IM_MODULE=ibus
export QT_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
EOF

3. ibus デーモンの自動起動確認

ibus-daemon -drx

4. 設定ツールで Mozc を追加

ibus-setup

よくある原因と確認ポイント

症状確認することen/jp 切替できるが変換されない
  -> Mozc が入力メソッドに追加されていない
再起動すると元に戻る
  -> 環境変数が .profile に書かれていない
特定のアプリだけ効かない
  -> GTK_IM_MODULE / QT_IM_MODULE の設定漏れ
Wayland 環境
  -> QT_IM_MODULE=wayland に変更が必要な場合あり

確認コマンド

# 現在の IME 確認
echo $GTK_IM_MODULE

# fcitx5 が動いているか確認
pgrep -a fcitx5

# Mozc がインストールされているか確認
dpkg -l | grep mozc

環境変数はログイン時に読み込まれるため、設定後は必ず再起動(またはログアウト→ログイン)が必要です。
どの IME(fcitx / ibus)を使っているかによって、対処方法が変わる場合があります。

おわりに

これでたいていの場合は解決すると思います。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?