# howto: getting ibus-anthy working with kde4 and opera11

## bpoint

I've been trying to get Japanese input working in KDE4 on a fresh Gentoo install for about a week now, and after scouring the net and trying various configurations, I finally have it just about working.  Hopefully this post will assist in helping anyone else get any similar problems fixed.

First of all, I originally tried using uim, but had compile issues with uim-1.6.0, and some applications just wouldn't work at all with it.  I then gave up, and went back to trying to get ibus to work.  I completely avoided scim, as it seems there are some issues with getting it to work properly (from the horror stories I read on the net).

In any case, the first things to emerge are:

```
emerge ibus-anthy ibus-qt
```

The current versions and USE flags for what I'm using are:

```
[ebuild   R   ] app-i18n/ibus-1.3.9  USE="X gconf python -doc -gtk (-introspection) -nls -vala" 0 kB

[ebuild   R   ] app-i18n/ibus-anthy-1.2.4  USE="-nls" 0 kB

[ebuild   R   ] app-i18n/ibus-qt-1.3.0  USE="-doc" 0 kB

```

Note that ibus-anthy will automatically pull in ibus as a dependency.  When ibus finishes emerging, the ebuild will show the following:

```
 * 3. Set the following in your user startup scripts

 *    such as .xinitrc, .xsession or .xprofile:

 * 

 *    export XMODIFIERS="@im=ibus"

 *    export GTK_IM_MODULE="ibus"

 *    export QT_IM_MODULE="xim"

 *    ibus-daemon -d -x
```

The QT_IM_MODULE is actually incorrect, it should be "ibus", not "xim".  It is also not necessary to manually start the ibus-daemon in your .xinitrc either.

Since this PC has a Japanese keyboard, and I intend to all users to be able enter Japanese, I added these exports to a new file in the xinitrc.d in the /etc/X11

folder (/etc/X11/xinit/xinitrc.d/85-ibus):

```
export GTK_IM_MODULE="ibus"

export QT_IM_MODULE="ibus"

export XMODIFIERS="@im=ibus"
```

I used a name of 85-ibus since ibus uses dbus, and 80-dbus initializes a dbus session for the user logging in.  After restarting your X session, you'll have an empty space on your system tray -- this is where the ibus icon should be but doesn't appear (I still haven't figured this one out, but since it's purely cosmetical, I really don't mind).  Right-click on the ibus space, and select preferences, or enter "ibus-setup" from a terminal.

Since the icon in the systray is broken, it's not really necessary, so I turned it off.  Having some feedback about the current input method is nice, so I also set Show language panel to "When active".  The initial keyboard shortcut for activating ibus is Ctrl+space, but if you have a Japanese keyboard like I do, you'll probably want the Zenkaku/Hankaku key to toggle it.  To do that, perform the following steps:

```
1) Click the "..." next to "Enable or disable" Keyboard Shortcuts

2) Delete any existing shortcuts, like Ctrl+space (optional)

3) Click the "..." next to "Key code"

4) Press the Zenkaku/Hankaku key and release it

5) Click "Add" to register the key (note that it registers as Release+Zenkaku_Hankaku, but this is fine)

6) Click OK

```

Note that you do not need anything for "Next input method" unless you intend to add more than one language conversion (anything other than English and Japanese).

Next, click on the Input Method tab and add "Japanese - Anthy", and that's pretty much the basics.  Most KDE4 applications will work fine (kwrite, konquerer, etc), but Opera probably won't.

To get Opera to work properly, you need to have a LANG environment variable set, preferably to UTF-8.  First ensure in /etc/locale.gen that you at least have a UTF-8 locale available:

```
en_US.UTF-8 UTF-8

ja_JP.UTF-8 UTF-8
```

Next, create (I had to create it at least) /etc/env.d/02locale with just the following:

```
LANG="en_US.UTF-8"
```

Then run etc-update (this is important!), and reboot.  When back in KDE, you should now be able to enter Japanese into Opera.

Finally, to get the Zenkaku/Hankaku key to work as a toggle, this page helped.  Basically, the key assignment when detecting the key seems to be incorrect due to the keymap.  I don't quite know or understand the details, but there are two options available.

```
First option:

1) Open the ibus preferences (or ibus-setup)

2) Click the Advanced tab

3) Disable "Use system keyboard layout"

4) Logout of KDE and log back in

5) Open ibus preferences again

6) Re-register the Zenkaku/Hankaku key (see above)

7) Re-enable "Use system keyboard layout" again

8) Logout of KDE and log back in again

```

or,

```
Second option:

1) Modify the /usr/share/ibus/keymaps/us file as shown in the link above
```

After all of this, you should be set (hopefully).   :Smile: 

I still don't have Japanese input in Firefox, but since I use Opera, it's not much of an issue to me.  Perhaps it's probably because of something with GTK, I'm not sure.  If anyone has any ideas about getting it to work, I'd like to hear them.

If anyone has any other questions or problems, just ask, and I'll try to help out!

----------

## tomk

Moved from Desktop Environments to Documentation, Tips & Tricks as it fits better here.

----------

## lo-jay

hi,

got ibus 1.2.0.20100111 working with chinese input (pinyin).

but the chinese characters in the pop-up window are super small -

where can i change this?

cheers

----------

## bpoint

Hello lo-jay!

 *lo-jay wrote:*   

> got ibus 1.2.0.20100111 working with chinese input (pinyin).
> 
> but the chinese characters in the pop-up window are super small -
> 
> where can i change this?

 

In the ibus preferences panel, there is a "Use custom font" setting which should help you.  However, you're using a rather old version of ibus (the latest is 1.3.9), so that could potentially be a problem.  I also found this post which might be related to your small font issue, but I recommend upgrading to the latest version of ibus first.

Hope this helps!

----------

## lo-jay

hey bpoint,

that works!

thanks a lot  :Very Happy: 

----------

## lo-jay

ok, just upgraded to app-i18n/ibus-1.3.9 -

and it stopped working:

running  *Quote:*   

> ibus-setup

 

i get

```
 ibus-setup

** Message: pygobject_register_sinkfunc is deprecated (GtkWindow)

** Message: pygobject_register_sinkfunc is deprecated (GtkInvisible)

** Message: pygobject_register_sinkfunc is deprecated (GtkObject)

(process:16855): Gtk-WARNING **: Locale not supported by C library.

        Using the fallback 'C' locale.

Traceback (most recent call last):

  File "/usr/share/ibus/setup/main.py", line 463, in <module>

    locale.setlocale(locale.LC_ALL, '')

  File "/usr/lib64/python2.6/locale.py", line 521, in setlocale

    return _setlocale(category, locale)

locale.Error: unsupported locale setting
```

what's that gonna tell me?

my locales look like this:

```
$ locale

locale: Cannot set LC_ALL to default locale: No such file or directory

LANG=de_DE.UTF-8

LC_CTYPE=zh_CN.gb2312

LC_NUMERIC=zh_CN

LC_TIME=en_US

LC_COLLATE=zh_CN

LC_MONETARY=en_US.UTF-8

LC_MESSAGES=en_US

LC_PAPER=zh_CN

LC_NAME=zh_CN

LC_ADDRESS=zh_CN

LC_TELEPHONE=zh_CN

LC_MEASUREMENT=zh_CN

LC_IDENTIFICATION=zh_CN

LC_ALL=

```

cheers again!

----------

## Dorsai!

I got a similar Problem since one of the last ibus upgrades. It worked very well before.

Now, when I left-click on the ibus icon, it does nothing, its not even saying "kein Eingabefenster" (no input window" which it said before whenever I tried to use it together with a not supported application.

My locals are:

```
locale

LANG=de_DE.UTF-8

LC_CTYPE="de_DE.UTF-8"

LC_NUMERIC="de_DE.UTF-8"

LC_TIME="de_DE.UTF-8"

LC_COLLATE="de_DE.UTF-8"

LC_MONETARY="de_DE.UTF-8"

LC_MESSAGES="de_DE.UTF-8"

LC_PAPER="de_DE.UTF-8"

LC_NAME="de_DE.UTF-8"

LC_ADDRESS="de_DE.UTF-8"

LC_TELEPHONE="de_DE.UTF-8"

LC_MEASUREMENT="de_DE.UTF-8"

LC_IDENTIFICATION="de_DE.UTF-8"

LC_ALL=de_DE.UTF-8

```

which I am sure is exactly the same as in the times when it worked.

----------

## lo-jay

dunno which language you're using ibus for, but in my case it's chinese

& i switched back to fcitx-4.0.0 which works with some of the locales 

set to chinese language.

cheers

----------

## bpoint

I just finished upgrading my Gentoo box and ibus-1.3.99 was pulled in with the update -- it stopped working here too.  There were two things causing it to not work for me:

1) I had set -python in my /etc/make.conf to cut down on some unneeded python dependencies.  According to this post, if python is not set, then ibus-setup isn't installed.  After adding:

```
app-i18n/ibus python
```

to /etc/portage/package.use and re-emerging ibus, ibus-setup came back.

2) ibus-daemon wasn't being started automatically.  I honestly am not sure how it even worked before, but after adding:

```
/usr/bin/ibus-daemon -d -x -r
```

to /etc/X11/xinit/xinitrc.d/85-ibus, then restarting my X session, ibus was happily working again.

Hope this helps fix any issues for anyone else!

----------

