1

The uim package provides different input methods like direct (None, use X keyboard mapping), beyeoru (Korean), anthy (Japanese).

It also provides several GUI tools for switching input methods (e.g. tray applet, toolbar, etc). You can also configure a hot-key for switching between two inputs (e.g. direct and beyeoru).

How can I command-line or programmatically switch between these input methods [direct, beyeoru, anthy] without the use of a hotkey or GUI?

7
  • Check out the xdotool package. – Gunnar Hjalmarsson Aug 16 '16 at 22:51
  • It may be possible via dbus. I personally use fcitx , and did write python script for that , so it may be possible to do the same for uim. I've never used it though, so will need to set it up first. – Sergiy Kolodyazhnyy Aug 16 '16 at 23:10
  • It does not seem to use dbus. I thought about xdotool but I actually think it might only be possible to toggle between the IME and direct rather than between altogether different IMEs (e.g. japanese to korean). 1/x – pztrick Aug 16 '16 at 23:32
  • This Python script monitors the relevant socket file that the GTK widgets communicate with. I had earlier tried to send to the socket using sensible parameters but could not get it work. github.com/kiike/scripts/blob/master/uim-eye.py – pztrick Aug 16 '16 at 23:33
  • 1
    @VladimirPanteleev It has been a very long time since I grokked uim but here is the source: gist.github.com/pztrick/028ecf0df7ad68d0173d2ec7bd6b84d8 I also remember having to edit some /usr/share and $HOME/.uim.d configs for my use case. Sample usage: /my/bin/uim-switch-im pinyin-big5 – pztrick Oct 27 '17 at 15:24
1

To distil what the toolbar apps and libuim are doing:

action=im_change_whole_desktop
input_method=anthy
printf "%s\n%s\n\n" "$action" "$input_method" | \
    nc -NU "$XDG_RUNTIME_DIR/uim/socket/uim-helper"

If you use a non-XDG distribution/environment, the socket will be in ~/.uim.d/socket/uim-helper instead.

$action can be im_change_whole_desktop, im_change_this_application_only or im_change_this_text_area_only.

To get a list of input methods, you can run uim-sh -e installed-im-list.

1
  • Accepting this as it appears correct but won't be able to test now, a year later. :) See OP comments for source to a program that may be useful to someone in the future... – pztrick Oct 27 '17 at 15:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.