suse-cjk 

http://www.suse.de/~mfabian/suse-cjk/node1.html

Automatic starting of an XIM server with the X11 session 

The default scripts used on SuSE Linux to start an X11 session will automatically attempt to start a suitable XIM server for the language7 used to start the X11 session.

The starting of the XIM server is done by the script ~/.xim, which is sourced by ~/.xinitrc or ~/.xsession. You can find the default SuSE versions of these scripts in /etc/skel. During the creation of a new user with YaST2, the files from /etc/skel will automatically be copied to the users home directory Thus, a newly created user will automatically have these files. Note that the user root is an exception, root will not have these files by default. Actually, root will not get any dot-files by default. If you are missing these files, copy the default versions from /etc/skel to your home directory.

Basically, the script ~/.xim checks the LC_CTYPE locale and tries to start the ``best''available XIM server for this locale.

A suitable XIM server will be started automatically, if any such server is installed (and, if necessary, a suitable conversion backend is installed and running).

For example, if kinput2 and Canna are installed and the cannaserver is running and there is no “better” Japanese input system for XIM installed, kinput2 will automatically start when you start an X11 session with

~$ LANG=ja_JP startx

If you don't start your X11 session with startx but rather use one of the display managers xdm, kdm, or wdm, you cannot choose the language anymore before starting your X11 session. The display managers run as user root and the X11 session started by them inherits the locale from the user root. Therefore, if you are using one of these display managers and want an XIM server to start automatically, you have to set the default language for the user root to the appropriate language. This is done by setting the variables RC_LANG and ROOT_USES_LANG in /etc/rc.config, for example

RC_LANG="ja_JP"
ROOT_USES_LANG="yes"

Then run SuSEconfig and restart your display manager.

If you are using the display manager gdm, you don't need to change the default language for the user root, because gdm has a menu to select the language before starting an X11 session. Unfortunately the other display managers don't have this feature.

Footnotes

Example 1. .. language7

the language is indicated by the LC_CTYPE locale.

Customizing XIM server startup 

If you want to know in detail how the XIM server startup is done, please have a look a the file ~/.xim in your home directory.

You may want to do this to adapt the starting of an XIM server to you personal preferences. For example

  • you may disagree on what the “best” available XIM server is.
  • you may want to start additional XIM servers, which would not start automatically for the language you use to start your X11-session.

As an Example, let's assume you usually start your X11 session in English, because you mostly use English and prefer that your window manager or desktop environment shows English menus, but nevertheless you always want to have the Japanese input server kinput2 running and always want to set the XMODIFIERS environment variable suitable for kinput2 because you often write Japanese texts. In that case, I recommend to edit your ~/.xim a bit like in the following example

case $tmplang in
    ja*)  # Japanese
         ... stuff for X11-sessions started in Japanese ...
ko*)  # Korean
     ... stuff for X11-sessions started in Korean ...
zh_*) # Chinese
     ... stuff for X11-sessions started in Chinese ...
    *)    # all other languages
         export XMODIFIERS="@im=kinput2"
         LANG=ja_JP LC_ALL=ja_JP kinput2 -xim -kinput -canna &
    ;;
esac

Add this last section “*)” for all languages not handled above, put the necessary commands to start kinput2 there and set the environment variable XMODIFIERS.

And remember to start all programs in your X11-session where you want to do Japanese input in a Japanese locale. If you have started your X11 session for example in English, programs started from a start menu of your window manager will usually start in an English locale. In that case, you have to explicitly specify a Japanese locale for the programs you want to run in Japanese mode by starting them like this:

~$ LANG=ja_JP program

In the following sections, the available XIM servers are explained in greater detail.