How can I change my fcitx input method from the terminal?

Solution 1:

The appropriate command is fcitx-remote -s <imname>, where <imname> is of course the name fcitx uses to refer to the input method. Sadly, these names are not documented either, but you can find them in your fcitx configuration file (in my system, it's ~/.config/fcitx/profile), where there's a list of all the enabled (also, all disabled) input methods.

In particular, the names for xkb layouts go something like fcitx-keyboard-XYZ. For example fcitx-keyboard-us for the US English QWERTY layout, or fcitx-keyboard-de-dvorak for a German Dvorak layout. As another example, the Mozc Japanese IM is called simply mozc.

The current input method (the equivalent of ibus engine without parameters) can be obtained from the same file, in the line that says IMName=<imname>. Be aware, however, that the scope of this variable depends on whether you share the state between windows or not, and on whether fcitx is active (the result of running fcitx-remote).