User:Isaac914/uim

From ArchWiki
Jump to navigation Jump to search

Category:Internationalization <-- re-add category

This page explains how to set up uim for various languages.

If you use SCIM, see Smart Common Input Method platform.

If you use IBus, see Ibus.

Installation

Note: You need to have east Asian fonts installed if you want to enter Chinese, Japanese, Korean or Vietnamese characters.

Using pacman

Install uim from the official repositories.

Compiling uim from source using PKGBUILD

The UIM package in the official Arch repositories(as of 1.8.6) is built with the following options enabled:

  • --with-anthy-utf8 - Enable Anthy(UTF-8) support
  • --with-qt4-immodule - Build Qt4 immodule
  • --with-qt4 - Build uim-tools for Qt4

If you need uim compiled with custom options, you may want to build uim from source. Check the official UIM wiki for a list of all options that can be enabled at compile time. You may want to use the ABS to create a custom pkgbuild for uim. An example option you can add to uim with a custom pkgbuild is --enable-kde4-applet, which gives you a KDE4 widget.

Configuring uim

Depending on how you manage your X session, you need to follow different steps to configure uim. If you use startx, xinit, or a graphic Display Manager, see #Environment variables. If you use systemd to manage your X session, go to #Using systemd

Environment variables

For uim to work properly, you need to export some environment variables that specify the used input method. Add the following to ~/.xprofile, ~/.xinitrc or ~/.xsession:

nano ~/.xprofile
export GTK_IM_MODULE='uim'
export QT_IM_MODULE='uim'
uim-xim &
export XMODIFIERS='@im=uim'
Note: Do not remove any of these four environment variables when you add an additional environment variable listed in the next section.

If you want to use the UIM-toolbar which allows you to view, control, and switch the current input method, add one of the following to .xprofile, .xsession, or .xinitrc:

  • For the GTK+ 2 toolbar: uim-toolbar-gtk &
  • For the GTK+ 3 toolbar: uim-toolbar-gtk3 &
  • For the QT4 toolbar: uim-toolbar-qt4 &


This will enable the uim-toolbar as a floating panel. If you also want a systray icon, add one of the following instead.

  • For GTK+ 2: uim-toolbar-gtk-systray &
  • For GTK+ 3: uim-toolbar-gtk3-systray &
Note: Alternatively, on GNOME, KDE, or XFCE, you can use the uim-toolbar panel applet. In xfce, install xfce-xfapplet-plugin to use uim-applet-gnome.
Note: The variables should be exported before starting your desktop environment, i.e. before "exec startxfce4" or similar. See below if you're using systemd to manage your X session.

Using systemd

If you are using systemd to manage your X session, you'll need to set the environment variables in your systemd session rather than an init script.

~/.config/systemd/user/uim-env.service
[Unit]
Description=uim environment initialization
Before=xorg.target

[Service]
Type=oneshot
ExecStart=/usr/bin/systemctl --user set-environment XMODIFIERS=@im=uim
ExecStart=/usr/bin/systemctl --user set-environment GTK_IM_MODULE=uim
ExecStart=/usr/bin/systemctl --user set-environment QT_IM_MODULE=uim
~/.config/systemd/user/uim.service
[Unit]
Description=uim daemon
Wants=uim-env.service
After=xorg.target

[Service]
ExecStart=/usr/bin/uim-xim
Restart=on-abort

[Install]
WantedBy=xorg.target
~/.config/systemd/user/uim-toolbar.service
[Unit]
Description=uim toolbar
PartOf=uim.service

[Service]
ExecStart=/usr/bin/uim-toolbar-of-your-choice
Restart=on-abort

[Install]
WantedBy=uim.service

Lastly, you'll need to enable the services:

 $ systemctl --user enable uim.service uim-toolbar.service

Activate input methods

Note: More detailed instructions on how to set up Korean and Japanese input are provided in sections below. Korean users should skip this section and go to Korean Input#uim-byeoru. Japanese users should skip this section and go to User:Isaac914/uim/Setting up Japanese Input in UIM

Open the uim preferences window by running :

$ uim-pref-gtk (Or, uim-pref-gtk3/uim-pref-qt4)

which opens a GUI.

Within "Global Settings", make sure that "Specify default IM" is checkmarked, then set your preferred input method as the default Input Method. You can also remove unused input methods from the list of enabled input methods.

  • Vietnamese input methods, as well as Hán-Việt input methods, are available as VIQR and m17n-vi-*.
  • Chinese input methods are available as New Pinyin(simplified), Pinyin(Unicode), Pinyin(Traditional), and m17n-zh-*

You can run uim-xim or restart X to test your settings.

Setting up hotkeys

Within "Global settings", you can set up a hotkey to switch between your IMEs. This is especially useful if you need to have type in several languages. Check the "Enable IM switching by Hotkey" checkbox, and set the IM switching key. By default, the Im switching hotkey is ctrl+Space.

You may also want to assign a hotkey to enable/disable your input method of choice. This allows you to quickly switch between your language and the raw keyboard input (often English) while typing. To do this, select the menu entry that says your_IM key bindings 1 in the Tree menu on the left side of the preferences window. From there, you can set various hotkeys to control the functions of the input method.

Provided everything went well you should be able to input the chosen language in X.

Configuring uim for Emacs

uim provides a software bridge for Emacs called uim.el. This section walks through setting up uim with Emacs using utf-8 encoding. Refer to the official uim wiki for more details.

Choosing how to call uim.el

There are two ways to call uim.el from Emacs: through the use of minor-mode or via LEIM(Library of Emacs Input Methods). Though the configuration is different for each, the basic functions are the same. If you need to switch between uim.el and other Emacs input methods frenquently, using the LEIM method is recommended.

Configuring minor-mode

If you want to use minor-mode to use uim.el, add the following to .emacs.d/init.el, or other files that you use to customize Emacs.

;; read uim.el
(require 'uim)
;; uncomment next and comment out previous to load uim.el on-demand
;; (autoload 'uim-mode "uim" nil t)

;; key-binding for activate uim (ex. C-\)
(global-set-key "\C-\\" 'uim-mode)
Configuring LEIM

If you wish to call uim.el through LEIM, add the following to .emacs.d/init.el or other files you use to customize Emacs, and specify the default input method.

;; read uim.el with LEIM initializing
(require 'uim-leim)

;; set default IM. Uncomment the one of the followings.
;(setq default-input-method "japanese-anthy-utf8-uim")        ; Anthy (UTF-8)
;(setq default-input-method "japanese-google-cgiapi-jp-uim")  ; Google-CGIAPI-Jp
;(setq default-input-method "japanese-mozc-uim")              ; Mozc

Ignoring C-SPC on uim.el

When you are assigning activation/deactivation of input method to C-SPC, C-SPC is stolen to switch input mode by uim.el while it is activated. To prevent the stealing and use for set-mark-command, add the followings into your .emacs.d/init.el or some other file for Emacs customizing.

(add-hook 'uim-load-hook
          '(lambda ()
             (define-key uim-mode-map [67108896] nil)
             (define-key uim-mode-map [0] nil)))


Disabling XIM on Emacs

When you are using input method on your desktop and assigning activation/deactivation of input method to C-SPC, you will be not able to use C-SPC/C-@ as set-mark-command on Emacs. To avoid this problem, add the following into your ~/.Xresources or ~/.Xdefaults. xim will be disabled on Emacs.

Emacs*UseXIM: false

Troubleshooting

Set the GTK_IM_MODULE variable, but uim still not works with GTK+ 2 applications

In case you already set the GTK_IM_MODULE environmental variable, but uim still not works with GTK+ 2 applications, you need to specify the location of gtk.immodules, which is created by and can be generated with gtk-query-immodules-2.0.

The default location is /etc/gtk-2.0/gtk.immodules for GTK+ 2.

You can do this with either the GTK_IM_MODULE_FILE variable (not recommended, it causes GTK+ 3 applications to see incompatible modules) or the im_module_file setting (recommended).

Add the following to /etc/gtk-2.0/gtkrc or ~/.gtkrc-2.0:

 im_module_file "/etc/gtk-2.0/gtk.immodules"

Cannot input Japanese on Opera

If you use Opera and cannot input Japanese with uim, try to edit environment variable as follows: Make sure to add follows in the beginning of /usr/bin/opera.

export XMODIFIERS='@im=uim'
export QT_IM_MODULE='xim'

Cannot type a consonant in Zenkaku mode

If you cannot type a consonant in Zenkaku mode, add follows to your config file.

   e.g.  vi ~/.uim.d/customs/custom-google-cgiapi-jp.scm
    
   (define ja-rk-rule-hoge
   (map
   (lambda (c)
   (list (cons (list c) ()) (list c c c)))
   '("b" "c" "d" "f" "g" "h" "j" "k" "l" "m"
   "p" "q" "r" "s" "t" "v" "w" "x" "y" "z"
   "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M"
   "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z")))
   (if (symbol-bound? 'ja-rk-rule-hoge)
   (set! ja-rk-rule (append ja-rk-rule-hoge ja-rk-rule)))

uim-toolbar-gtk-systray: tray icon is crushed

Though some of DE, WM or panel application may provide only one icon space per application on system-tray/notification-area, uim-toolbar-gtk-systray displays some icons on it by default so those icons are crushed. Choose just one of them to solve it. The steps to display only 'Input mode' icon for example as follows:

  1. Run uim-pref-gtk.
  2. Click 'Toolbar' on 'Group' list.
  3. Take the all checkmarks off.
  4. Click 'Anthy', 'Anthy (UTF-8)' or 'Mozc' which you are using on 'Group' list.
  5. Click Edit button in 'Toolbar' box > 'Enable toolbar buttons' line.
  6. Enable only 'Input mode' and click 'Close' button.
  7. Click 'OK' button to close uim-pref-gtk.

The tray icon will be displayed "あ" (Hiragana mode) or "ー" (Direct mode).

UIM toolbar icons are hard to see with a dark theme

You can choose icons for darker background (uim 1.6.0 or later).

  1. Run uim-perf-gtk
  2. Click 'Toolbar' on 'Group' list.
  3. Check 'Use icon for dark background'.

See also

uim
uim official document
uim on wikibooks
Fonts
Japanese fonts showcase
modified Japanese fonts