プロジェクト

全般

プロフィール

CentOS 7 X上の日本語入力をuim-anthyに

動機

CentOS 7のXアプリケーションの画面をWindows上に表示させたい。例えば、Windows 10のWSL上でCentOS 7を動かし、GUIを持つアプリケーションの画面をWindows上のXサーバーに飛ばしてWindows上のデスクトップ上のアプリケーションであるかのように扱いたい。ただし、GNOMEデスクトップ全体をWindowsには持ってきたくない。

この環境でCentOS 7のアプリで日本語入力をする方法の一つにuimとuim-anthyを使うことができるか探ってみたい。

方法

uimとuim-anthyはCentOS 7の標準パッケージには含まれていない。ソースからビルドするか、Fedora 19 or 20のRPMパッケージを持ってくるかがある。Red Hat Enterprise Linux 7は、Fedora 19をベースとしており、Fedora 20の更新を取り込んでいるので、これらがCentOS 7に比較的近しいFedoraバージョンである。

Fedoraのrpmパッケージ入手

https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/20/Everything/x86_64/os/Packages/

  • eb-4.4.3-1.fc20.x86_64.rpm
  • libgcroots-0.2.3-6.fc20.x86_64.rpm
  • uim-1.8.6-3.fc20.x86_64.rpm
  • uim-anthy-1.8.6-3.fc20.x86_64.rpm
  • uim-gtk2-1.8.6-3.fc20.x86_64.rpm
  • uim-gtk3-1.8.6-3.fc20.x86_64.rpm
  • anthy-9100h-24.fc20.x86_64.rpm

インストール

CentOS 7の標準パッケージから次をインストール

~$ sudo yum localinstall eb-4.4.3-1.fc20.x86_64.rpm libgcroots-0.2.3-6.fc20.x86_64.rpm \
uim-1.8.6-3.fc20.x86_64.rpm uim-anthy-1.8.6-3.fc20.x86_64.rpm anthy-9100h-24.fc20.x86_64.rpm \
uim-gtk2-1.8.6-3.fc20.x86_64.rpm uim-gtk3-1.8.6-3.fc20.x86_64.rpm 

uimのエンジンをanthyに設定

# uim-module-manager --register anthy

個人設定

~/.uim

(define default-im-name 'anthy)
(define-key generic-on-key? '("<Control> "))
(define-key generic-off-key? '("<Control> " "escape"))

anthyをデフォルトとし、漢字入力のオンをCtrl+Space、漢字入力のオフをCtrl+SpaceおよびEscapeキーに割当てています。

環境変数設定

export XMODIFIERS=@im=uim
export UIM_CANDWIN_PROG=uim-candwin-gtk
export GTK_IM_MODULE=uim
export QT_IM_MODULE=uim

動作確認

xterm 上で、uim-fep

  • xterm を起動
  • xterm 上で uim-fep を実行
  • xterm の画面左下に、anthy[An- R] と表示され、Ctrl+Spaceキーを押すと、その表示がanthy[AnあR]と表示が変わり、プロンプト箇所が日本語入力となる

GTKアプリケーションでuim

Javaで作られたアプリケーション(例:NetBeans)で日本語入力を行ってみます。

~/.uim で日本語入力を切り替えるキーバインドを、Ctrl-j に変更(Ctrl-SPCはコード補完と重なるので)

(define default-im-name 'anthy)
(define-key generic-on-key? '("<Control>j"))
(define-key generic-off-key? '("<Control>j" "escape"))
  • uim-ximをバックグラウンドで実行
    $ uim-xim &
  • GTKアプリケーションを実行
    上述~/.uimで設定したCtrl-jで日本語入力のオン・オフができます。
実行されているプロセス

NetBeans上で日本語入力ができた時点で実行中のプロセスは次

~$ ps -a
  PID TTY          TIME CMD
  158 tty1     00:00:00 wslbridge-backe
  190 tty2     00:00:00 wslbridge-backe
  240 pts/1    00:00:02 uim-xim
  242 pts/1    00:00:00 uim-helper-serv
  491 pts/1    00:00:00 uim-candwin-gtk
 1693 pts/0    00:00:00 bash
 1878 pts/0    00:01:34 java
 1970 pts/1    00:00:00 ps


ほぼ4年前に更新