fcitx / fcitx5

maybe a new fcitx.
1.62k stars 117 forks source link

Flatpak-only setup? #287

Closed teohhanhui closed 3 years ago

teohhanhui commented 3 years ago

Background

I'm using openSUSE MicroOS, which has an immutable root filesystem. All packages installed / updated to the base system require a system restart. Therefore, it'd be ideal to be able to install fcitx entirely through flatpak only.

Steps to reproduce

  1. I've followed the instructions at https://fcitx-im.org/wiki/Install_Fcitx_5#Install_Fcitx_5_from_Flatpak

    So I've installed org.fcitx.Fcitx5 and org.fcitx.Fcitx5.Addon.ChineseAddons flatpak packages from flathub.

  2. I've copied /etc/xdg/autostart/fcitx-autostart.desktop from within the org.fcitx.Fcitx5 flatpak package, to ~/.config/autostart/fcitx-autostart.desktop on the host.

    And I've modified the ~/.config/autostart/fcitx-autostart.desktop file as follows:

    Exec=flatpak run --command=fcitx-autostart org.fcitx.Fcitx5
    Icon=org.fcitx.Fcitx5
  3. I've created the ~/.config/environment.d/envvars.conf file as follows:

    GTK_IM_MODULE=fcitx
    QT_IM_MODULE=fcitx
    XMODIFIERS=@im=fcitx
  4. Reboot.

Problem / questions

So far so good.

flatpak run --command=fcitx-diagnose org.fcitx.Fcitx5 output: ``` # System Info: 1. `uname -a`: Linux envy-x360 5.12.9-1-default fcitx/flatpak-fcitx5#1 SMP Thu Jun 3 07:44:58 UTC 2021 (f17eb01) x86_64 GNU/Linux 2. `lsb_release`: `lsb_release` not found. 3. `/etc/lsb-release`: `/etc/lsb-release` not found. 4. `/etc/os-release`: NAME="KDE Flatpak runtime" VERSION="5.15" VERSION_ID="5.15" ID=org.kde.Platform PRETTY_NAME="KDE Flatpak runtime" BUG_REPORT_URL=https://bugs.kde.org/ 5. Desktop Environment: Desktop environment is `gnome3`. 6. Bash Version: BASH_VERSION='5.1.4(1)-release' # Environment: 1. DISPLAY: DISPLAY=':99.0' 2. Keyboard Layout: 1. `setxkbmap`: `setxkbmap` not found. 2. `xprop`: `xprop` not found. 3. Locale: 1. All locale: C C.utf8 en_AG en_AU en_AU.utf8 en_BW en_BW.utf8 en_CA en_CA.utf8 en_DK en_DK.utf8 en_GB en_GB.utf8 en_HK en_HK.utf8 en_IE en_IE@euro en_IE.utf8 en_IL en_IN en_NG en_NZ en_NZ.utf8 en_PH en_PH.utf8 en_SC.utf8 en_SG en_SG.utf8 en_US en_US.utf8 en_ZA en_ZA.utf8 en_ZM en_ZW en_ZW.utf8 POSIX 2. Current locale: LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL= 4. Directories: 1. Home: /home/teohhanhui 2. `${XDG_CONFIG_HOME}`: Environment variable `XDG_CONFIG_HOME` is set to `/home/teohhanhui/.var/app/org.fcitx.Fcitx5/config`. Current value of `XDG_CONFIG_HOME` is `~/.var/app/org.fcitx.Fcitx5/config` (`/home/teohhanhui/.var/app/org.fcitx.Fcitx5/config`). 3. Fcitx Settings Directory: Current fcitx settings directory is `~/.var/app/org.fcitx.Fcitx5/config/fcitx` (`/home/teohhanhui/.var/app/org.fcitx.Fcitx5/config/fcitx`). 5. Current user: The script is run as teohhanhui (1000). # Fcitx State: 1. executable: Found fcitx at `/usr/bin/fcitx`. 2. version: Fcitx version: `4.2.9.7` 3. process: **Fcitx is not running.** **Please check the Configure link of your distribution in [Beginner's Guide](http://fcitx-im.org/wiki/Beginner%27s_Guide) for how to setup fcitx autostart.** # Fcitx Configure UI: 1. Config Tool Wrapper: Found fcitx-configtool at `/usr/bin/fcitx-configtool`. 2. Config GUI for gtk2: **Config GUI for gtk2 not found.** 3. Config GUI for gtk3: **Config GUI for gtk3 not found.** 4. Config GUI for kde: **`kcmshell4` not found.** **Cannot find a GUI config tool, please install one of `kcm-fcitx`, `fcitx-config-gtk2`, or `fcitx-config-gtk3`.** # Frontends setup: ## Xim: 1. `${XMODIFIERS}`: Environment variable XMODIFIERS is set to "@im=fcitx" correctly. Xim Server Name from Environment variable is fcitx. 2. XIM_SERVERS on root window: **`xprop` not found.** ## Qt: 1. qt4 - `${QT4_IM_MODULE}`: Environment variable QT_IM_MODULE is set to "fcitx" correctly. 2. qt5 - `${QT_IM_MODULE}`: Environment variable QT_IM_MODULE is set to "fcitx" correctly. 3. Qt IM module files: Found unknown fcitx qt module: `/app/lib/fcitx5/qt5/libfcitx-quickphrase-editor5.so`. **Cannot find fcitx input method module for Qt4.** **Cannot find fcitx input method module for Qt5.** ## Gtk: 1. gtk - `${GTK_IM_MODULE}`: Environment variable GTK_IM_MODULE is set to "fcitx" correctly. 2. `gtk-query-immodules`: 1. gtk 2: **Cannot find `gtk-query-immodules` for gtk 2** **Cannot find fcitx im module for gtk 2.** 2. gtk 3: Found `gtk-query-immodules` for gtk `3.24.21` at `/usr/bin/gtk-query-immodules-3.0`. Version Line: # Created by /usr/bin/gtk-query-immodules-3.0 from gtk+-3.24.21 Found fcitx im modules for gtk `3.24.21`. "/usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules/im-fcitx.so" "fcitx" "Fcitx (Flexible Input Method Framework)" "fcitx" "/usr/share/locale" "ja:ko:zh:*" 3. Gtk IM module cache: 1. gtk 2: **Cannot find immodules cache for gtk 2** **Cannot find fcitx im module for gtk 2 in cache.** 2. gtk 3: Found immodules cache for gtk `3.24.21` at `/usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules.cache`. Version Line: # Created by gtk-query-immodules-3.0 from gtk+-3.24.21 Found fcitx im modules for gtk `3.24.21`. "/usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules/im-fcitx.so" "fcitx" "Fcitx (Flexible Input Method Framework)" "fcitx" "/usr/share/locale" "ja:ko:zh:*" 4. Gtk IM module files: 1. gtk 2: All found Gtk 2 immodule files exist. 2. gtk 3: All found Gtk 3 immodule files exist. # Configuration: ## Fcitx Addons: 1. Addon Config Dir: Found fcitx addon config directory: `/usr/share/fcitx/addon`. 2. Addon List: 1. Found 16 enabled addons: fcitx-autoeng fcitx-chttrans fcitx-clipboard fcitx-dbus fcitx-freedesktop-notify fcitx-fullwidth-char fcitx-imselector fcitx-ipc fcitx-ipcportal fcitx-keyboard fcitx-kimpanel-ui fcitx-notificationitem fcitx-punc fcitx-quickphrase fcitx-remote fcitx-unicode 2. Found 1 disabled addons: fcitx-qw 3. Addon Libraries: All libraries for all addons are found. 4. User Interface: Found 1 enabled user interface addons: fcitx-kimpanel-ui **Cannot find kimpanel dbus interface or enabled non-kimpanel user interface.** ## Input Methods: 1. Found 1 enabled input methods: fcitx-keyboard-us 2. Default input methods: You only have one keyboard input method enabled. You may want to add another input method to input other languages. # Log: 1. `date`: Tue 08 Jun 2021 09:10:40 PM +08 2. `~/.var/app/org.fcitx.Fcitx5/config/fcitx/log/`: total 0 3. `~/.var/app/org.fcitx.Fcitx5/config/fcitx/log/crash.log`: `~/.var/app/org.fcitx.Fcitx5/config/fcitx/log/crash.log` not found. ```

It doesn't use ~/.config/fcitx and ~/.config/fcitx5 for some reason. Passing --env=XDG_CONFIG_HOME=$HOME/.config doesn't seem to do anything, maybe due to https://github.com/flathub/io.neovim.nvim/issues/2#issuecomment-452923174

And it's not able to detect the running fcitx process, but the process seems to be running just fine.

sudo journalctl -b | grep -i fcitx output: ``` Jun 08 20:45:33 envy-x360 dbus-daemon[2016]: [session uid=1000 pid=2016] Activating via systemd: service name='org.freedesktop.Flatpak' unit='flatpak-session-helper.service' requested by ':1.53' (uid=1000 pid=2332 comm="flatpak run --command=fcitx-autostart org.fcitx.Fc") Jun 08 20:45:34 envy-x360 dbus-daemon[2016]: [session uid=1000 pid=2016] Activating via systemd: service name='org.freedesktop.portal.Documents' unit='xdg-document-portal.service' requested by ':1.53' (uid=1000 pid=2332 comm="flatpak run --command=fcitx-autostart org.fcitx.Fc") Jun 08 20:45:34 envy-x360 systemd[1998]: Started app-flatpak-org.fcitx.Fcitx5-2332.scope. Jun 08 20:45:34 envy-x360 systemd[1998]: app-gnome-fcitx\x2dautostart-2332.scope: Succeeded. Jun 08 20:45:36 envy-x360 fcitx-autostart.desktop[2412]: Fcitx seems is not running Jun 08 20:45:36 envy-x360 fcitx-autostart.desktop[2554]: (INFO-7 addon.c:151) Load Addon Config File:fcitx-autoeng.conf Jun 08 20:45:36 envy-x360 fcitx-autostart.desktop[2554]: (INFO-7 addon.c:151) Load Addon Config File:fcitx-chttrans.conf Jun 08 20:45:36 envy-x360 fcitx-autostart.desktop[2554]: (INFO-7 addon.c:151) Load Addon Config File:fcitx-clipboard.conf Jun 08 20:45:36 envy-x360 fcitx-autostart.desktop[2554]: (INFO-7 addon.c:151) Load Addon Config File:fcitx-dbus.conf Jun 08 20:45:36 envy-x360 fcitx-autostart.desktop[2554]: (INFO-7 addon.c:151) Load Addon Config File:fcitx-freedesktop-notify.conf Jun 08 20:45:36 envy-x360 fcitx-autostart.desktop[2554]: (INFO-7 addon.c:151) Load Addon Config File:fcitx-fullwidth-char.conf Jun 08 20:45:36 envy-x360 fcitx-autostart.desktop[2554]: (INFO-7 addon.c:151) Load Addon Config File:fcitx-imselector.conf Jun 08 20:45:36 envy-x360 fcitx-autostart.desktop[2554]: (INFO-7 addon.c:151) Load Addon Config File:fcitx-ipc.conf Jun 08 20:45:36 envy-x360 fcitx-autostart.desktop[2554]: (INFO-7 addon.c:151) Load Addon Config File:fcitx-ipcportal.conf Jun 08 20:45:36 envy-x360 fcitx-autostart.desktop[2554]: (INFO-7 addon.c:151) Load Addon Config File:fcitx-keyboard.conf Jun 08 20:45:36 envy-x360 fcitx-autostart.desktop[2554]: (INFO-7 addon.c:151) Load Addon Config File:fcitx-kimpanel-ui.conf Jun 08 20:45:36 envy-x360 fcitx-autostart.desktop[2554]: (INFO-7 addon.c:151) Load Addon Config File:fcitx-notificationitem.conf Jun 08 20:45:36 envy-x360 fcitx-autostart.desktop[2554]: (INFO-7 addon.c:151) Load Addon Config File:fcitx-punc.conf Jun 08 20:45:36 envy-x360 fcitx-autostart.desktop[2554]: (INFO-7 addon.c:151) Load Addon Config File:fcitx-quickphrase.conf Jun 08 20:45:36 envy-x360 fcitx-autostart.desktop[2554]: (INFO-7 addon.c:151) Load Addon Config File:fcitx-qw.conf Jun 08 20:45:36 envy-x360 fcitx-autostart.desktop[2554]: (INFO-7 addon.c:151) Load Addon Config File:fcitx-remote-module.conf Jun 08 20:45:36 envy-x360 fcitx-autostart.desktop[2554]: (INFO-7 addon.c:151) Load Addon Config File:fcitx-unicode.conf Jun 08 20:45:36 envy-x360 fcitx-autostart.desktop[2555]: sh: line 1: dbus-launch: command not found Jun 08 20:46:33 envy-x360 systemd[1998]: Started app-flatpak-org.fcitx.Fcitx5-2874.scope. Jun 08 20:46:35 envy-x360 systemd[1998]: app-flatpak-org.fcitx.Fcitx5-2874.scope: Succeeded. Jun 08 20:46:35 envy-x360 systemd[1998]: app-flatpak-org.fcitx.Fcitx5-2874.scope: Consumed 2.490s CPU time. Jun 08 21:10:38 envy-x360 systemd[1998]: Started app-flatpak-org.fcitx.Fcitx5-7100.scope. Jun 08 21:10:40 envy-x360 systemd[1998]: app-flatpak-org.fcitx.Fcitx5-7100.scope: Succeeded. Jun 08 21:10:40 envy-x360 systemd[1998]: app-flatpak-org.fcitx.Fcitx5-7100.scope: Consumed 2.443s CPU time. Jun 08 21:18:14 envy-x360 systemd[1998]: Started app-flatpak-org.fcitx.Fcitx5-8944.scope. Jun 08 21:18:16 envy-x360 systemd[1998]: app-flatpak-org.fcitx.Fcitx5-8944.scope: Succeeded. Jun 08 21:18:16 envy-x360 systemd[1998]: app-flatpak-org.fcitx.Fcitx5-8944.scope: Consumed 2.698s CPU time. Jun 08 21:18:49 envy-x360 systemd[1998]: Started app-flatpak-org.fcitx.Fcitx5-10578.scope. Jun 08 21:18:50 envy-x360 systemd[1998]: app-flatpak-org.fcitx.Fcitx5-10578.scope: Succeeded. Jun 08 21:19:17 envy-x360 systemd[1998]: Started app-flatpak-org.fcitx.Fcitx5-11081.scope. Jun 08 21:19:19 envy-x360 systemd[1998]: app-flatpak-org.fcitx.Fcitx5-11081.scope: Succeeded. Jun 08 21:19:19 envy-x360 systemd[1998]: app-flatpak-org.fcitx.Fcitx5-11081.scope: Consumed 2.509s CPU time. Jun 08 21:19:34 envy-x360 systemd[1998]: Started app-flatpak-org.fcitx.Fcitx5-12708.scope. Jun 08 21:19:36 envy-x360 systemd[1998]: app-flatpak-org.fcitx.Fcitx5-12708.scope: Succeeded. Jun 08 21:19:36 envy-x360 systemd[1998]: app-flatpak-org.fcitx.Fcitx5-12708.scope: Consumed 2.513s CPU time. Jun 08 21:20:00 envy-x360 polkitd[1017]: Registered Authentication Agent for unix-process:14350:209116 (system bus name :1.117 [flatpak info -M org.fcitx.Fcitx5], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) ```

So now the main problem is I don't have access to fcitx-config-gtk3. Perhaps I can try installing it in my toolbox (https://github.com/kubic-project/microos-toolbox), but it'd be nice to have it as a flatpak package.

Also, is this kind of setup supported? I saw https://github.com/fcitx/fcitx5/issues/108#issuecomment-683123132 where you've mentioned this so I guess it's a yes?

Use flatpak fcitx + flatpak fcitx engine + flatpak/host app is possible.

teohhanhui commented 3 years ago

If I run fcitx-diagnose from within the toolbox container, it's able to detect the running process.

So I guess it's due to sandbox limitation that fcitx-diagnose is not working from within the flatpak.

teohhanhui commented 3 years ago

I think I've realized my mistake. The correct thing to do is:

ln -s ~/.local/share/flatpak/exports/share/applications/org.fcitx.Fcitx5.desktop ~/.config/autostart/org.fcitx.Fcitx5.desktop
teohhanhui commented 3 years ago

Now there's only one thing which is still not working. fcitx IME doesn't work in host apps.

wengxt commented 3 years ago

You still need some im module on your host (not possible to be provided by flatpak).

You can use either: xim (which could be buggy), fcitx 4, fcitx5, or even ibus. I suggest fcitx4 one if fcitx5 is not available by your distro.

https://fcitx-im.org/wiki/Install_Fcitx_5#Install_Fcitx_5_from_Flatpak https://fcitx-im.org/wiki/Input_method_related_environment_variables

wengxt commented 3 years ago

In terms of generally available by default without install new package (my guessing),

Use following values might work, you can also play with other values.

XMODIFIERS=@im=fcitx # For x11
GTK_IM_MODULE=xim # For Gtk
QT4_IM_MODULE=xim # For Qt4
QT_IM_MODULE=ibus # For Qt5+

Also, there's no "fcitx-autostart" in fcitx5, nor "fcitx-diagnose". There's only "fcitx5-diagnose".

Also there's no fcitx-config-gtk3 for fcitx5 and org.fcitx.Fcitx5 already bundles the fcitx5-configtool within it, you can access it easily via the fcitx tray icon.