インストール - Fcitx5
概要
Fcitx5は、Fcitxの後継であり、軽量コアを備えたインプットメソッドフレームワークであり、アドオンを介して追加の言語サポートを提供する。
Fcitx5のインストール (リポジトリの追加)
SUSEの公式リポジトリからM17Nリポジトリを追加する。
# SLE / openSUSE Leap sudo zypper addrepo 'https://download.opensuse.org/repositories/M17N/$releasever/' M17N または sudo zypper addrepo 'https://download.opensuse.org/repositories/home:/ftake:/branches:/M17N/buildtools_$releasever/' ftake
追加したリポジトリを更新する。
sudo zypper refresh
Fcitx5をインストールする。
Fcitx5の設定ツールは自動的にインストールされる。
# KKCを使用する場合 sudo zypper install fcitx5-kkc fcitx5-table-other # SKKを使用する場合 sudo zypper install fcitx5-skk fcitx5-table-other # Mozcを使用する場合 sudo zypper install fcitx5-mozc fcitx5-table-other # Anthyを使用する場合(Anthyは開発を再開している) sudo zypper install fcitx5-anthy fcitx5-table-other
Fcitx5のインストール (ソースコードからインストール)
ソースコードからインストールする前に
まず最初に、~/.profileファイル等に各ライブラリの環境変数を設定する。
vi ~/.profile
export PATH="/<Fcitx5のインストールディレクトリ>/bin:$PATH"
export LD_LIBRARY_PATH="/<Fcitx5のインストールディレクトリ>/lib64:/<Fcitx5のインストールディレクトリ>/lib:$LD_LIBRARY_PATH"
export PKG_CONFIG_PATH="$(pkg-config --variable pc_path pkg-config)"
export PKG_CONFIG_PATH="/<Fcitx5のインストールディレクトリ>/lib64/pkgconfig:/<Fcitx5のインストールディレクトリ>/lib/pkgconfig:/<Fcitx5のインストールディレクトリ>/share/pkgconfig:$PKG_CONFIG_PATH"
export PYTHONPATH="/<Fcitx5のインストールディレクトリ>/lib64/python2.7/site-packages:$PYTHONPATH"
XCB-IMDKitのインストール
まず、XCB-IMDKitをGithubからダウンロードする。
git clone https://github.com/fcitx/xcb-imdkit.git cd xcb-imdkit
XCB-IMDKitのビルドに必要なライブラリをインストールする。
sudo zypper install libxcb-devel xcb-util-devel xcb-util-keysyms-devel libut1 uthash-devel
XCB IMDkitをビルドおよびインストールする。
mkdir build && cd build cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=<Fcitx5のインストールディレクトリ> .. make -j $(nproc) make install
Emojiモジュールのインストール
EmojiモジュールのGithubにアクセスして、Emojiモジュールのソースコードをダウンロードする。
tar xf cldr-emoji-annotation-<バージョン>.tar.gz cd cldr-emoji-annotation-<バージョン>
または、git clone
コマンドを使用して、Emojiモジュールのソースコードをダウンロードする。
git clone https://github.com/fujiwarat/cldr-emoji-annotation.git cd cldr-emoji-annotation
Emojiモジュールをビルドおよびインストールする。
# Tarballからビルドする場合 mkdir build && cd build ../configure --prefix=<Fcitx5のインストールディレクトリ> --enable-dtd make -j $(nproc) make install # Githubのソースコードからビルドする場合 ./autogen.sh mkdir build && cd build ../configure --prefix=<Fcitx5のインストールディレクトリ> make -j $(nproc) make install
XCB IMDkitおよびEmojiモジュールを読み込むため、~/.profileファイル等に環境変数を追記する。
export LD_LIBRARY_PATH="/<Fcitx5のインストールディレクトリ>/lib64" export PKG_CONFIG_PATH="$(pkg-config --variable pc_path pkg-config)" export PKG_CONFIG_PATH="/<Fcitx5のインストールディレクトリ>/lib64/pkgconfig:/<Fcitx5のインストールディレクトリ>/share/pkgconfig:$PKG_CONFIG_PATH"
Fcitx5のインストール
次に、Fcitx5のビルドに必要なライブラリをインストールする。
# RHEL sudo dnf install cairo-devel pango-devel dbus-devel dbus-glib-devel qt-devel intltool cmake gtk3-devel gtk2-devel \ gcc-c++ libicu-devel opencc-devel # SUSE sudo zypper install cairo-devel pango-devel dbus-1-devel dbus-1-glib-devel intltool cmake extra-cmake-modules libexpat-devel \ gtk3-devel gtk2-devel gdk-pixbuf-devel gcc-c++ libicu-devel opencc-devel libevent-devel fmt-devel xcb-util-wm-devel \ libxkbcommon-x11-devel libxkbfile-devel iso-codes-devel enchant-1-devel enchant-devel libjson-c-devel \ systemd-devel libtevent-devel libxkbcommon-devel wayland-protocols-devel
Fcitx5のGithubから、Fcitx5のソースコードをダウンロードする。
ダウンロードしたファイルを解凍する。
tar xf <バージョン>.tar.gz cd <バージョン>
または、git clone
コマンドを実行して、ソースコードをダウンロードする。
git clone https://github.com/fcitx/fcitx5.git cd fcitx5
Fcitxのビルドディレクトリを作成する。
cd <Fcitxのソースコードがあるディレクトリ> mkdir build && cd build
Fcitxをビルドおよびインストールする。
cmake .. -DCMAKE_CXX_COMPILER=<G++8.5以降のG++のフルパス> \ -DCMAKE_INSTALL_PREFIX=<Fcitx5のインストールディレクトリ> \ -DCMAKE_BUILD_TYPE=Release \ -DENABLE_GTK3_IM_MODULE=ON \ -DENABLE_QT_IM_MODULE=ON \ -DENABLE_WAYLAND=Off # Waylandで使用しない場合 make -j $(nproc) make install
もし、Fcitx5をホームディレクトリ等の任意のディレクトリにインストールする場合、~/.profileファイル等に環境変数を設定する。
vi ~/.profile
# ~/.profileファイル等
export PATH="/<Fcitx5のインストールディレクトリ>/bin:$PATH"
export LD_LIBRARY_PATH="/<Fcitx5のインストールディレクトリ>/lib:$LD_LIBRARY_PATH"
export PKG_CONFIG_PATH="$(pkg-config --variable pc_path pkg-config)"
export PKG_CONFIG_PATH="/<Fcitx5のインストールディレクトリ>/lib/pkgconfig:$PKG_CONFIG_PATH"
Fcitx5のD-Busサービスファイル (セッションバス) を作成する。
sudo vi /usr/share/dbus-1/services/org.fcitx.Fcitx5.service
# /usr/share/dbus-1/services/org.fcitx.Fcitx5.serviceファイル
[D-BUS Service]
Name=org.fcitx.Fcitx5
Exec=/<Fcitx5のインストールディレクトリ>/bin/fcitx5
Fcitx5-qtのインストール
Fcitx5-qtのGithubにアクセスして、ソースコードをダウンロードする。
tar xf <バージョン>.tar.gz cd <バージョン>
または、git clone
コマンドを使用して、Fcitx5-qtのソースコードをダウンロードする。
git clone https://github.com/fcitx/fcitx5-qt.git cd fcitx5-qt
Fcitx5-qtのビルドに必要なライブラリをインストールする。
sudo zypper install libQt5Core-devel libQt5Gui-devel libQt5Widgets-devel libQt5DBus-devel libQt5Concurrent-devel \ libqt5-qtbase-devel libqt5-qtbase-private-headers-devel
Fcitx5-qtをビルドおよびインストールする。
mkdir build && cd build
cmake -DCMAKE_C_COMPILER=<GCC 8以降のGCCのパス> -DCMAKE_CXX_COMPILER=<G++ 8以降のG++のパス> \
-DCMAKE_INSTALL_PREFIX=<Fcitx5のインストールディレクトリ> \
-DCMAKE_INSTALL_QT5PLUGINDIR=/<Fcitx5のインストールディレクトリ>/lib64/qt5/plugins/platforminputcontexts \ # 未指定でも可
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_QT4=OFF \ # デフォルトで無効になっている
-DENABLE_QT6=OFF \ # デフォルトでは無効になっているため、有効にする場合はON
を指定する
..
make -j $(nproc)
make install または sudo make install
手動でlibfcitx5platforminputcontextplugin.soファイルを/usr/lib64/qt5/plugins/platforminputcontextsディレクトリにコピーする必要があるかもしれない。
sudo cp libfcitx5platforminputcontextplugin.so /usr/lib64/qt5/plugins/platforminputcontexts/
Fcitx5-gtkのインストール
Fcitx5-gtkのGithubにアクセスして、ソースコードをダウンロードする。
tar xf <バージョン>.tar.gz cd <バージョン>
または、git clone
コマンドを使用して、Fcitx5-gtkのソースコードをダウンロードする。
git clone https://github.com/fcitx/fcitx5-gtk.git cd fcitx5-gtk
Fcitx5-gtkのビルドに必要なライブラリをインストールする。
sudo zypper install gtk3-devel gobject-introspection-devel gtk4-devel # GTK 4を有効にする場合
Fcitx5-gtkをビルドおよびインストールする。
cmake -DCMAKE_C_COMPILER=<GCC 8以降のGCCのパス> -DCMAKE_CXX_COMPILER=<G++ 8以降のG++のパス> \ -DCMAKE_INSTALL_PREFIX=<Fcitx5のインストールディレクトリ> \ # 未指定でも可 -DGOBJECT_INTROSPECTION_GIRDIR=/<Fcitx5のインストールディレクトリ>/share/gir-1.0 \ # 未指定でも可 -DGOBJECT_INTROSPECTION_TYPELIBDIR=/<Fcitx5のインストールディレクトリ>/lib64/girepository-1.0 \ # 未指定でも可 -DCMAKE_BUILD_TYPE=Release \ -DENABLE_GTK2_IM_MODULE=OFF \ # GTK 2を無効にする場合 -DENABLE_GTK4_IM_MODULE=OFF \ # GTK 4を無効にする場合 .. make -j $(nproc) make install または sudo make install
手動でFcitxG-1.0.typelibファイルおよびFcitxG-1.0.girファイルを、以下に示すディレクトリにコピーする必要があるかもしれない。
sudo cp FcitxG-1.0.typelib /usr/lib64/girepository-1.0/ sudo cp FcitxG-1.0.gir /usr/share/gir-1.0/
Marisaのインストール
MarisaのGithubにアクセスして、ソースコードをダウンロードする。
tar xf v<バージョン>.tar.gz cd v<バージョン>
または、git clone
コマンドを使用して、Marisaのソースコードをダウンロードする。
git clone https://github.com/s-yata/marisa-trie.git cd marisa-trie
Marisaのビルドに必要なライブラリをダウンロードする。
sudo zypper install python-devel
Marisaをビルドおよびインストールする。
この時、ビルドディレクトリは作成しないことに注意する。
autoreconf -i ./configure --prefix=<Fcitx5のインストールディレクトリ> --enable-native-code make -j $(nproc) make install
MarisaのPython向けのライブラリも併せてインストールする。
cd bindings/python python setup.py build python setup.py install --prefix=<Fcitx5のインストールディレクトリ>
Anthy-Unicodeのインストール (任意 : Fcitx5-Anthyを使用する場合)
Anthyとは、LGPLでライセンスされた日本語入力メソッドエンジンである。
2009年以降、開発が停止していたが、2021年に元開発者の田畑氏の合意の下で「Anthy Unicode」なる計画がTakao Fujiwara氏ら有志の手により開始している。
2023年2月4日より、Anthy Unicodeが利用可能になった。利用可能になったのは以下に示すパッケージである。
- anthy-unicode (本体)
- kasumi-unicode (辞書ツール)
- fcitx-anthy-unicode (Fcitx4用ラッパー)
- fcitx5-anthy-unicode (Fcitx5用ラッパー)
- ibus-anthy-unicode (IBus用ラッパー)
詳細は、OSDNのWebサイトから閲覧することができる。
Anthy UnicodeのGithub : https://github.com/fujiwarat/anthy-unicode
Anthy-UnicodeのGithubにアクセスして、ソースコードをダウンロードする。
ダウンロードしたファイルを解凍する。
tar xf anthy-unicode-<バージョン>.tar.gz cd anthy-unicode-<バージョン>
または、git clone
コマンドを実行して、Anthy-Unicodeのソースコードをダウンロードする。
git clone https://github.com/fujiwarat/anthy-unicode.git cd anthy-unicode
Anthy-Unicodeをビルドおよびインストールする。
autoreconf -i mkdir build && cd build ../configure --prefix=<Fcitx5のインストールディレクトリ> make -j $(nproc) make install
Kasumi-Unicodeのインストール (任意 : Fcitx5-Anthyを使用する場合)
霞 (Kasumi-Unicode) は、シンプルなAnthy個人辞書管理ツールである。
Kasumi-Unicodeのビルドに必要なライブラリをインストールする。
# SUSE sudo zypper install make gcc gcc-c++ gtk3-devel anthy-devel # パッケージ管理システムからAnthy-Unicodeをインストールしている場合
Kasumi-UnicodeのGithubにアクセスして、ソースコードをダウンロードする。
ダウンロードしたファイルを解凍する。
tar xf kasumi-unicode-<バージョン>.tar.gz cd kasumi-unicode-<バージョン>
または、git clone
コマンドを実行して、Kasumi-Unicodeのソースコードをダウンロードする。
git clone https://github.com/fujiwarat/kasumi-unicode.git cd kasumi-unicode
Kasumi-Unicodeをビルドおよびインストールする。
autoreconf -i mkdir build && cd build ../configure --prefix=<Fcitx5のインストールディレクトリ> make -j $(nproc) make install
Fcitx5-Anthyのインストール (任意 : Fcitx5-Anthyを使用する場合)
Fcitx5-Anthyのビルドに必要なライブラリをダウンロードする。
sudo zypper install pkg-config gettext-runtime gettext-tools make cmake extra-cmake-modules \ anthy-devel # パッケージ管理システムからAnthyをインストールしている場合 fcitx5-devel # パッケージ管理システムからFcitx5をインストールしている場合
Fcitx5-AnthyのGithubにアクセスして、ソースコードをダウンロードする。
ダウンロードしたファイルを解凍する。
tar xf fcitx5-anthy-<バージョン>.tar.gz cd fcitx5-anthy-<バージョン>
Fcitx5-Anthyをビルドおよびインストールする。
cmake -DCMAKE_INSTALL_PREFIX=<Fcitx5のインストールディレクトリ> -DCMAKE_BUILD_TYPE=Release .. make -j $(nproc) make install
libKKCおよびlibKKC Dataのインストール (任意 : Fcitx5-KKCを使用する場合)
libKKCのGithubにアクセスして、ソースコードをダウンロードする。
tar xf libkkc-<バージョン>.tar.gz cd libkkc-<バージョン>
または、git clone
コマンドを使用して、libKKCのソースコードをダウンロードする。
git clone https://github.com/ueno/libkkc.git cd libKKC
libKKCのビルドに必要なライブラリをダウンロードする。
sudo zypper install intltool libgee-devel json-glib-devel gobject-introspection-devel \ vala libvala-0_54-0 libvala-0_54-devel python3-marisa marisa-devel xcb-util-wm-devel
libKKCをビルドおよびインストールする。
export PATH="/<Fcitx5のインストールディレクトリ>/bin:$PATH"; \ export LD_LIBRARY_PATH="/<Fcitx5のインストールディレクトリ>/lib64:$LD_LIBRARY_PATH"; \ export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$(pkg-config --variable pc_path pkg-config)" \ export PKG_CONFIG_PATH="/<Fcitx5のインストールディレクトリ>/lib64/pkgconfig:$PKG_CONFIG_PATH"; \ export PYTHONPATH="/<Fcitx5のインストールディレクトリ>/lib64/python2.7/site-packages:$PYTHONPATH" ./autogen.sh --prefix=<Fcitx5のインストールディレクトリ> make -j $(nproc) make install
次に、libKKC DataのGithubにアクセスして、ソースコードをダウンロードする。
tar xf libkkc-data-<バージョン>.tar.gz cd libkkc-data-<バージョン>
libKKC Dataをビルドおよびインストールする。
./configure --prefix=<Fcitx5のインストールディレクトリ> make -j $(nproc) make install
Fcitx5-KKCの動作に必要な依存関係のライブラリをインストールする。
sudo zypper install libgee-0_8-2 typelib-1_0-Gee-0_8 libxcb-ewmh2
Fcitx5-KKCのインストール (任意 : Fcitx5-KKCを使用する場合)
Fcitx5-KKCのGithubにアクセスして、ソースコードをダウンロードする。
ダウンロードしたファイルを解凍する。
tar xf <バージョン>.tar.gz cd <バージョン>
または、git clone
コマンドを使用して、Fcitx5-gtkのソースコードをダウンロードする。
git clone https://github.com/fcitx/fcitx5-kkc.git cd fcitx5-kkc
Fcitx-KKCのビルドに必要なライブラリをインストールする。
sudo zypper install gettext libgee-devel json-glib-devel pkg-config libQt5Core-devel libQt5Gui-devel libQt5Widgets-devel
Fcitx5-KKCをビルドおよびインストールする。
cmake -DCMAKE_INSTALL_PREFIX=<Fcitx5のインストールディレクトリ> -DCMAKE_BUILD_TYPE=Release .. make -j $(nproc) make install
Fcitx5-ConfigToolのインストール
Fcitx5-ConfigToolのGithubにアクセスして、ソースコードをダウンロードする。
tar xf <バージョン>.tar.gz cd <バージョン>
または、git clone
コマンドを使用して、Fcitx5-ConfigToolのソースコードをダウンロードする。
git clone https://github.com/fcitx/fcitx5-configtool.git cd fcitx5-configtool
Fcitx-ConfigToolのビルドに必要なライブラリをインストールする。
sudo zypper install gettext libgee-devel json-glib-devel pkg-config \ libxkbcommon-devel libxkbfile-devel iso-codes-devel plasma-framework-devel kiconthemes-devel \ kcoreaddons-devel ki18n-devel kirigami2-devel kpackage-devel kwidgetsaddons-devel kitemviews-devel kdeclarative-devel \ libqt5-qtsvg-devel libQt5QuickControls2-devel libQt5Concurrent-devel libqt5-qtx11extras-devel
Fcitx5-ConfigToolをビルドおよびインストールする。
cmake -DCMAKE_INSTALL_PREFIX=<Fcitx5のインストールディレクトリ> -DCMAKE_BUILD_TYPE=Release .. make -j $(nproc) make install
Fcitx5のデスクトップエントリファイルの作成
Fcitx5の自動起動を設定するファイルを作成する。
vi ~/.share/local/applications/org.fcitx.Fcitx5.desktop # または sudo vi /usr/share/applications/org.fcitx.Fcitx5.desktop
[Desktop Entry]
Type=Application
Name=Fcitx 5
Name[ja]=Fcitx 5
GenericName=Input Method
GenericName[ja]=入力メソッド
Comment=Start Input Method
Comment[ja]=入力メソッドを開始
Exec=/<Fcitx5のインストールディレクトリ>/bin/fcitx5
Icon=fcitx
Terminal=false
Categories=System;Utility;X-SuSE-DesktopUtility;
StartupNotify=false
X-GNOME-AutoRestart=false
X-GNOME-Autostart-Notify=false
X-KDE-autostart-after=panel
X-KDE-StartupNotify=false
X-KDE-Wayland-VirtualKeyboard=true
Fcitx5の自動起動設定
Fcitx5の自動起動を設定するファイルを作成する。
vi ~/.config/autostart/org.fcitx.Fcitx5.desktop # または sudo vi /etc/xdg/autostart/org.fcitx.Fcitx5.desktop
# ~/.config/autostart/org.fcitx.Fcitx5.desktopファイル
# または
# /etc/xdg/autostart/org.fcitx.Fcitx5.desktopファイル
[Desktop Entry]
Type=Application
Name[ja]=Fcitx 5
Name=Fcitx 5
GenericName[ja]=入力メソッド
GenericName=Input Method
Comment[ja]=入力メソッドを開始
Comment=Start Input Method
Exec=/<Fcitx5のインストールディレクトリ>/bin/fcitx5
Icon=fcitx
Categories=System;Utility;X-SuSE-DesktopUtility;
Terminal=false
StartupNotify=false
X-GNOME-AutoRestart=false
X-GNOME-Autostart-Notify=false
X-KDE-autostart-after=panel
X-KDE-StartupNotify=false
X-KDE-Wayland-VirtualKeyboard=true
D-Bus設定ファイルの作成
Fcitx5のD-Bus設定ファイルを作成する。
sudo vi /usr/share/dbus-1/services/org.fcitx.Fcitx5.service
# /usr/share/dbus-1/services/org.fcitx.Fcitx5.serviceファイル
[D-BUS Service]
Name=org.fcitx.Fcitx5
Exec=/<Fcitx5のインストールディレクトリ>/bin/fcitx5
Mozcのインストール (ソースコードからインストール)
ソースコードのダウンロード
Mozcのソースコードをダウンロードする。
Mozcをビルドするには、GCC 8以降が必要となる。
git clone --depth 1 https://github.com/fcitx/mozc.git cd mozc git submodule update --init --recursive cd src # または git clone https://github.com/google/mozc.git -b master --single-branch --recursive cd mozc/src
Mozcのビルドに必要な依存関係のライブラリをインストールする。
sudo zypper install git curl unzip bzip2 update-desktop-files pkg-config make ninja gcc10-c++ zlib-devel protobuf-devel \ bazel6 bazel-rules-cc-source bazel-apple-support-source bazel-workspaces \ bazel-rules-java-source bazel-rules-proto-source \ bazel-rules-python-source bazel-rules-swift-source bazel-skylib-source \ qt6-core-devel qt6-gui-devel qt6-widgets-devel \ ibus-devel fcitx5-devel # Fcitx5をパッケージ管理システムからインストールしている場合
通常のLinux環境でMozcを構築する場合は、以下のファイルを修正する必要がある。
- src/config.bzl
- インストールパス等の指定する。
- src/.bazelrc
- コンパイラのフラグ等を指定する。
- src/WORKSPACE.bazel
- ビルドの依存関係。
インストールディレクトリの設定
必要ならば、srcディレクトリにあるconfig.bzlファイルを編集して、インストールディレクトリを変更する。
vi mozc/src/config.bzl
# mozc/src/config.bzlファイル LINUX_MOZC_BROWSER_COMMAND = "/usr/bin/xdg-open" LINUX_MOZC_ICONS_DIR = "/<Mozcのインストールディクトリ>/share/icons/mozc" LINUX_MOZC_SERVER_DIR = "/<Mozcのインストールディクトリ>/lib/mozc" LINUX_MOZC_DOCUMENT_DIR = LINUX_MOZC_SERVER_DIR + "/documents" IBUS_COMPONENT_DIR = "/<Mozcのインストールディクトリ>/share/ibus/component" IBUS_MOZC_INSTALL_DIR = "/<Mozcのインストールディクトリ>/share/ibus-mozc" IBUS_MOZC_ICON_PATH = IBUS_MOZC_INSTALL_DIR + "/product_icon.png" IBUS_MOZC_PATH = "/<Mozcのインストールディクトリ>/lib/ibus-mozc/ibus-engine-mozc" EMACS_MOZC_CLIENT_DIR = "/<Mozcのインストールディクトリ>/share/emacs/site-lisp/emacs-mozc" EMACS_MOZC_HELPER_DIR = "/<Mozcのインストールディクトリ>/bin"
Bazelの設定ファイルの作成と変更
WORKSPACEの編集
src/WORKSPACE.bazelファイルを編集して、以下に示す設定を追記する。
vi src/WORKSPACE.bazel
- パッケージ管理システムからFcitx5をインストールしている場合
# src/WORKSPACE.bazelファイル ## 138行目あたり # Fcitx # pkg_config_repository does not work because pkgconfig --cflags-only-I fcitx returns nothing new_local_repository( name = "fcitx", # This path should be updated per the environment. path = "/usr", # For Debian build_file = "BUILD.fcitx.bazel", ) # Fcitx 5 pkg_config_repository( name = "fcitx5", packages = ["Fcitx5Module", "Fcitx5Core"], )
- ソースコードからFcitx5をインストールしている場合
# src/WORKSPACE.bazelファイル ## 138行目あたり # Fcitx # pkg_config_repository does not work because pkgconfig --cflags-only-I fcitx returns nothing new_local_repository( name = "fcitx", # This path should be updated per the environment. path = "/usr", # For Debian build_file = "BUILD.fcitx.bazel", ) # Fcitx 5 new_local_repository( name = "fcitx5", path = "/<Fcitx5のインストールディレクトリ>", build_file = "BUILD.fcitx5.bazel", )
src/BUILD.fcitx.bazelファイルを作成する。
vi src/BUILD.fcitx.bazel
# src/BUILD.fcitx.bazelファイル package( default_visibility = ["//visibility:public"], ) cc_library( name = "fcitx", hdrs = glob([ "include/fcitx/**", "include/fcitx-config/**", "include/fcitx-utils/**", ]), copts = ["-pthread"], includes = [ "include", ], linkopts = [ "-lfcitx-core", "-lfcitx-config", "-lfcitx-utils", ], )
また、ソースコードからFcitx5をインストールしている場合は、src/BUILD.fcitx5.bazelファイルを作成する。
vi src/BUILD.fcitx5.bazel
# src/BUILD.fcitx5.bazelファイル package( default_visibility = ["//visibility:public"], ) cc_library( name = "fcitx5", srcs = glob(["lib64/libFcitx5Core.so*", "lib64/libFcitx5Utils.so*", "lib64/libFcitx5Config.so*", ]), hdrs = glob([ "include/Fcitx5/**", "include/Fcitx5/Module/**", "include/Fcitx5/Core/**", "include/Fcitx5/Config/**", "include/Fcitx5/Utils/**", ]), copts = ["-pthread"], includes = [ "include/Fcitx5/Module", "include/Fcitx5/Core", "include/Fcitx5/Config", "include/Fcitx5/Utils", ], linkopts = [ "-lFcitx5Core", "-lFcitx5Config", "-lFcitx5Utils", ], )
Mozcの設定ファイルの変更
vi src/unix/fcitx5/mozc.conf
# src/unix/fcitx5/mozc.confファイル
[InputMethod]
Name=Mozc
#Icon=fcitx-mozc
Icon=mozc
Label=あ
LangCode=ja
Addon=mozc
Configurable=True
vi src/unix/fcitx5/mozc-addon.conf
# src/unix/fcitx5/mozc-addon.confファイル
[Addon]
Name=Mozc
Category=InputMethod
#Library=fcitx5-mozc
Library=mozc
Type=SharedLibrary
OnDemand=True
Configurable=True
[Addon/OptionalDependencies]
0=clipboard
Python 3.6を使用している場合
vi src/base/gen_config_file_stream_data.py
# src/base/gen_config_file_stream_data.pyファイル
# 68行目あたり
## 編集前
output.write('constexpr FileData kFileData[] = {\n')
for path in path_list:
output.write(' {"%s", "' % os.path.basename(path))
with open(path, 'rb') as stream:
while (byte := stream.read(1)):
output.write(r'\x' + byte.hex())
output.write('"},\n')
output.write('};\n')
## 編集後
output.write('constexpr FileData kFileData[] = {\n')
for path in path_list:
output.write(' {"%s", "' % os.path.basename(path))
with open(path, 'rb') as stream:
byte = stream.read(1)
while (byte):
output.write(r'\x' + byte.hex())
byte = stream.read(1)
output.write('"},\n')
output.write('};\n')
Mozcのウインドウレンダリングの変更
vi src/renderer/qt/qt_window_manager.cc
// src/renderer/qt/qt_window_manager.ccファイル
// 35行目あたり
// 編集前
#include "base/logging.h"
#include "protocol/candidates.pb.h"
#include "absl/strings/str_cat.h"
#include "renderer/renderer_style_handler.h"
#include "renderer/window_util.h"
// 編集後
#include "absl/strings/str_cat.h"
#include "base/logging.h"
#include "protocol/candidates.pb.h"
#include "renderer/renderer_style_handler.h"
#include "renderer/window_util.h"
// src/renderer/qt/qt_window_manager.ccファイル
// 344行目あたり
// 追加
struct VirtualRect {
const QScreen* screen;
const Rect rect;
VirtualRect(const QScreen* screen, const Rect rect): screen(screen), rect(rect) {}
};
Rect TranslateToVirtualRectWithScreen(const QScreen *screen, const Rect& native_rect) {
const double device_pixel_ratio = screen->devicePixelRatio();
// screen_left, screen_top have the save value in both virtual and native coordinate
const int screen_left = screen->geometry().x();
const int screen_top = screen->geometry().y();
const int vx = (native_rect.Left() - screen_left) / device_pixel_ratio + screen_left;
const int vy = (native_rect.Top() - screen_top) / device_pixel_ratio + screen_top;
return Rect(vx, vy, native_rect.Width() / device_pixel_ratio, native_rect.Height() / device_pixel_ratio);
}
VirtualRect TranslateToVirtualRect(const Rect& native_rect) {
for (const QScreen *screen: QGuiApplication::screens()) {
Rect rect = TranslateToVirtualRectWithScreen(screen, native_rect);
const QRect screen_rect = screen->geometry();
// Use (top left) to locate a screen
if (screen_rect.contains(rect.Left(), rect.Top())) {
return VirtualRect(screen, rect);
}
}
// fall back to primary screen
const QScreen *screen = QGuiApplication::primaryScreen();
Rect point = TranslateToVirtualRectWithScreen(screen, native_rect);
return VirtualRect(screen, point);
}
// src/renderer/qt/qt_window_manager.ccファイル
// 379行目あたり
// 編集前
Point QtWindowManager::GetWindowPosition(
const commands::RendererCommand &command, const Size &win_size) {
const Rect preedit_rect = GetRect(command.preedit_rectangle());
const Point win_pos = Point(preedit_rect.Left(), preedit_rect.Bottom());
const Rect monitor_rect = GetMonitorRect(win_pos.x, win_pos.y);
const Point offset_to_column1(kColumn0Width, 0);
const Rect adjusted_win_geometry =
WindowUtil::GetWindowRectForMainWindowFromTargetPointAndPreedit(
win_pos, preedit_rect, win_size, offset_to_column1, monitor_rect,
/* vertical */ false); // Only support horizontal window yet.
return adjusted_win_geometry.origin;
}
// 編集後
Point QtWindowManager::GetWindowPosition(
const commands::RendererCommand &command, const Size &win_size) {
const Rect native_preedit_rect = GetRect(command.preedit_rectangle());
const VirtualRect preedit_rect = TranslateToVirtualRect(native_preedit_rect);
const Point win_pos = Point(preedit_rect.rect.Left(), preedit_rect.rect.Bottom());
const Rect monitor_rect = GetRect(preedit_rect.screen->geometry());
const Point offset_to_column1(kColumn0Width, 0);
const Rect adjusted_win_geometry =
WindowUtil::GetWindowRectForMainWindowFromTargetPointAndPreedit(
win_pos, preedit_rect.rect, win_size, offset_to_column1, monitor_rect,
/* vertical */ false); // Only support horizontal window yet.
return adjusted_win_geometry.origin;
}
IBus-Mozcの設定
vi src/unix/ibus/gen_mozc_xml.py
# src/unix/ibus/gen_mozc_xml.pyファイル
# 261行目あたり
# 編集前
}, {
'name': 'mozc-off',
'longname': product_name + ':A_',
'layout': 'default',
'layout_variant': '',
'layout_option': '',
'rank': 99,
'symbol': 'A',
'composition_mode': 'DIRECT',
}]
# 編集後
}, {
'name': 'mozc-off',
'longname': product_name + ':A_',
'layout': 'default',
'layout_variant': '',
'layout_option': '',
'rank': 99,
'symbol': 'A',
'composition_mode': 'DIRECT',
}, {
'name': 'mozc-jp-jp',
'longname': product_name + " - JP layout",
'layout': 'jp',
'layout_variant': '',
'layout_option': '',
'rank': 0,
}, {
'name': 'mozc-us',
'longname': product_name + " - US layout",
'layout': 'us',
'layout_variant': '',
'layout_option': '',
'rank': 0,
}, {
'name': 'mozc-dv',
'longname': product_name + " - US Dvorak layout",
'layout': 'us',
'layout_variant': 'dvorak',
'layout_option': '',
'rank': 0,
}]
Mozcのビルド
Fcitx5-Mozc、Mozcサーバ、Mozcツールをビルドおよびインストールする。
# Fcitx 5をソースコードからインストールしている場合
FCITX5_DIR="<Fcitx5のインストールディレクトリ>"; \
export PATH="$FCITX5_DIR/bin:$PATH"; \
export LD_LIBRARY_PATH="$FCITX5_DIR/lib64:$FCITX5_DIR/lib:$LD_LIBRARY_PATH"; \
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$(pkg-config --variable pc_path pkg-config)"; \
export PKG_CONFIG_PATH="$FCITX5_DIR/lib64/pkgconfig:$FCITX5_DIR/lib/pkgconfig:$PKG_CONFIG_PATH"
bazel build package --action_env CC=<GCC8以降のパス> --action_env CXX=<G++8以降のパス> \ //unix/fcitx5:fcitx5-mozc.so \ -c opt --force_pic --config oss_linux \ --jobs $(nproc) \ --strip=never \ --sandbox_debug \ --verbose_failures \ -s # または bazel build --action_env CC=<GCC8以降のパス> --action_env CXX=<G++8以降のパス> \ -c opt --copt=-fPIC --config oss_linux \ unix/fcitx5:fcitx5-mozc.so server:mozc_server gui/tool:mozc_tool renderer:gtk_mozc_renderer \ --verbose_failures
ビルドされたMozcファイル群が、src/bazel-binディレクトリに出力される。
Mozcファイル群を、以下に示すディレクトリに配置する。
ただし、Mozcのインストールディレクトリを変更している場合は、変更した設定に合わせてMozcファイル群を配置する必要がある。
# デフォルトのインストールディレクトリ (SUSE) sudp cp bazel-bin/unix/fcitx5/fcitx5-mozc.so /usr/lib64/fcitx5/mozc.so # ファイル名をmozc.so変更する必要がある sudo cp bazel-bin/server/mozc_server /usr/lib64/mozc/ sudo cp bazel-bin/gui/tool/mozc_tool /usr/lib64/mozc/ # インストールディレクトリを変更している場合 cp bazel-bin/unix/fcitx5/fcitx5-mozc.so /<Mozcのインストールディレクトリ>/lib64/fcitx5/mozc.so # ファイル名をmozc.so変更する必要がある cp bazel-bin/server/mozc_server /<Mozcのインストールディレクトリ>/lib/mozc/ cp bazel-bin/gui/tool/mozc_tool /<Mozcのインストールディレクトリ>/lib/mozc/
※注意
必要であれば、src/scripts/install_fcitx5_bazelファイルおよびsrc/scripts/install_server_bazelファイルの内容を参照する。
Mozcの設定ファイルの作成
Mozcのアドオン設定ファイル、および、インプットメソッド設定ファイルを作成する。
vi /<Mozcのインストールディレクトリ>/share/fcitx5/addon/mozc.conf # または sudo vi /usr/share/fcitx5/addon/mozc.conf
# /<Mozcのインストールディレクトリ>/share/fcitx5/addon/mozc.conf
# または
# /usr/share/fcitx5/addon/mozc.conf
[Addon]
Type=SharedLibrary
Name=Mozc
Category=InputMethod
Library=mozc
OnDemand=True
Configurable=True
[Addon/OptionalDependencies]
0=clipboard
vi /<Mozcのインストールディレクトリ>/share/fcitx5/inputmethod/mozc.conf # または sudo vi /usr/share/fcitx5/inputmethod/mozc.conf
# /<Mozcのインストールディレクトリ>/share/fcitx5/inputmethod/mozc.conf
# または
# /usr/share/fcitx5/inputmethod/mozc.conf
[InputMethod]
Name=Mozc
Icon=mozc
Label=あ
LangCode=ja
Addon=mozc
Configurable=True
Fcitx5の有効化
X11の場合
Fcitx5を有効にするには、~/.ximファイルを編集する。
# SUSE vi ~/.xim
~/.ximファイル export INPUT_METHOD="fcitx5" export XMODIFIERS="@im=fcitx5" export GTK_IM_MODULE="fcitx5" export QT_IM_MODULE="fcitx5" fcitx5 &
最後に、PCを再起動する。
Waylandの場合
最新のFcitxとiBusでは、Xのプロトコルアダプタを介して、基本的なWaylandサポートを備えている。
今後は、Waylandを直接サポートする予定である。
Waylandで入力メソッドを有効にするには、/etc/environmentファイル、または、~/.pam_environmentファイルに以下の内容を追記する。
なお、~/.xprofileファイル、~/.profileファイル、~/.bashrcファイル、~/.xinitrcファイルは設定不要である。
sudo vi /etc/environment または vi ~/.pam_environment
# /etc/environmentファイル または ~/.pam_environmentファイル INPUT_METHOD=fcitx5 XMODIFIERS=@im=fcitx5 GTK_IM_MODULE=fcitx5 QT_IM_MODULE=fcitx5
最後に、PCを再起動する。