NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.2k stars 14.2k forks source link

Fcitx5 doesn't work on GNOME Wayland #129442

Open sei40kr opened 3 years ago

sei40kr commented 3 years ago

Describe the bug Fcitx 5 doesn't work on Wayland.

To Reproduce Enable GNOME 4 & Fcitx 5.

{
  services.xserver = {
    displayManager.gdm.enable = true;
    desktopManager.gnome.enable = true;
  };
  i18n.inputMethod = {
    enabled = "fcitx5";
   fcitx5.addons = with pkgs; [ fcitx5-mozc ];
  };
}
  1. Configure Fcitx with Mozc
  2. Make sure no browser processes (ex. google-chrome, firefox) are not running
  3. Open a browser app via the GNOME application launcher
  4. Can't enable Mozc in the browser session (can't switch input method, can't make Mozc working even if we switch the input method by fcitx5-remote)
  5. Kill the browser sessions
  6. Open a browser app via command line in a terminal
  7. This time we can make Mozc working

Expected behavior Fcitx 5 & Mozc is working in a browser session run by the GNOME application launcher.

Notify maintainers @poscat0x04 @Vonfry

Metadata

 - system: `"x86_64-linux"`
 - host os: `Linux 5.10.45, NixOS, 21.11.20210626.f84d5fb (Porcupine)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 3.0pre20200829_f156513`
 - channels(root): `""`
 - channels(sei40kr): `"nixpkgs-21.05.1205.b72bde7c4a1"`
 - nixpkgs: `/home/sei40kr/.nix-defexpr/channels/nixpkgs`
jtojnar commented 3 years ago

Did you re-log in after enabling fcitx? It sets some environment variables and GNOME Shell will not see them until restarted, whereas terminal will source profile on startup, getting the latest enviromnent.

jansol commented 3 years ago

Also is this Wayland or X11 GNOME?

Vonfry commented 3 years ago

As talking above, I think the problem is that when gnome starts, fcitx5 isn't started or the environment variable isn't passed, therefore applications don't handle special action for input method.

You can open a pure terminal in gnome to have environment run in gnome, for example, not loading any profiles and initial scripts like .bash_profile, .bashrc and /etc/profile. Then run fcitx5-diagnose. Note, runing bash --noprofile with a opened temrminal is useless, because the environment variable in profiles are inherited.

By the way, I use xmonad without any desktop managers, and fcitx5 is worked fine. So does my friend who uses KDE.

Seong Yong-ju @.***> writes:

Describe the bug Fcitx 5 don't work in browser apps run by the GNOME application launcher.

To Reproduce Enable GNOME 4 & Fcitx 5.

{
  services.xserver = {
    displayManager.gdm.enable = true;
    desktopManager.gnome.enable = true;
  };
  i18n.inputMethod = {
    enabled = "fcitx5";
   fcitx5.addons = with pkgs; [ fcitx5-mozc ];
  };
}
  1. Configure Fcitx with Mozc
  2. Make sure no browser processes (ex. google-chrome, firefox) are not running
  3. Open a browser app via the GNOME application launcher
  4. Can't enable Mozc in the browser session (can't switch input method, can't make Mozc working even if we switch the input method by fcitx5-remote)
  5. Kill the browser sessions
  6. Open a browser app via command line in a terminal
  7. This time we can make Mozc working

Expected behavior Fcitx 5 & Mozc is working in a browser session run by the GNOME application launcher.

Notify maintainers @poscat0x04 @Vonfry

Metadata

 - system: `"x86_64-linux"`
 - host os: `Linux 5.10.45, NixOS, 21.11.20210626.f84d5fb (Porcupine)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 3.0pre20200829_f156513`
 - channels(root): `""`
 - channels(sei40kr): `"nixpkgs-21.05.1205.b72bde7c4a1"`
 - nixpkgs: `/home/sei40kr/.nix-defexpr/channels/nixpkgs`
sei40kr commented 3 years ago

Thank you for your quick responses.

@jtojnar

Did you re-log in after enabling fcitx?

Yes, I tried.

@jansol

Also is this Wayland or X11 GNOME?

Wayland

@Vonfry I tried to press Alt+F2 and open sh, and run env | less there.

Results of env | less
``` LD_LIBRARY_PATH= XDG_MENU_PREFIX=gnome- LANG=en_US.UTF-8 GDM_LANG=en_US.UTF-8 MANAGERPID=2319 DISPLAY=:0 INVOCATION_ID=ba8e976c7a5e4606bc76cc8a239bd26a ALACRITTY_LOG=/tmp/Alacritty-321428.log LOCALE_ARCHIVE_2_27=/nix/store/4w3l4vbgm0wj04mz38ifxh14s7s7qc5y-glibc-locales-2.32-48/lib/locale/locale-archive COLORTERM=truecolor USERNAME=sei40kr MOZ_PLUGIN_PATH=/home/sei40kr/.nix-profile/lib/mozilla/plugins:/etc/profiles/per-user/sei40kr/lib/mozilla/plugins:/nix/var/nix/profiles/default/lib/mozilla/plugins:/run/current-system/sw/lib/mozilla/plugins KDEDIRS=/home/sei40kr/.nix-profile:/etc/profiles/per-user/sei40kr:/nix/var/nix/profiles/default:/run/current-system/sw NIX_GSETTINGS_OVERRIDES_DIR=/nix/store/pwpy2jg8kgb12nlkfqp4x3vndfar7lw6-nixos-gsettings-desktop-schemas/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas QTWEBKIT_PLUGIN_PATH=/home/sei40kr/.nix-profile/lib/mozilla/plugins/:/etc/profiles/per-user/sei40kr/lib/mozilla/plugins/:/nix/var/nix/profiles/default/lib/mozilla/plugins/:/run/current-system/sw/lib/mozilla/plugins/ SSH_AUTH_SOCK=/run/user/1000/keyring/ssh USER=sei40kr DESKTOP_SESSION=gnome TZDIR=/etc/zoneinfo CUPS_DATADIR=/nix/store/jq8z5l622ib2ciqp6ymnlz8qw7m25xcs-cups-progs/share/cups LIBEXEC_PATH=/home/sei40kr/.nix-profile/lib/libexec:/etc/profiles/per-user/sei40kr/lib/libexec:/nix/var/nix/profiles/default/lib/libexec:/run/current-system/sw/lib/libexec WAYLAND_DISPLAY=wayland-0 PWD=/home/sei40kr NIX_PATH=nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels HOME=/home/sei40kr LC_CTYPE=ja_JP.UTF-8 JOURNAL_STREAM=8:1665465 XDG_SESSION_TYPE=wayland GTK_PATH=/home/sei40kr/.nix-profile/lib/gtk-2.0:/home/sei40kr/.nix-profile/lib/gtk-3.0:/etc/profiles/per-user/sei40kr/lib/gtk-2.0:/etc/profiles/per-user/sei40kr/lib/gtk-3.0:/nix/var/nix/profiles/default/lib/gtk-2.0:/nix/var/nix/profiles/default/lib/gtk-3.0:/run/current-system/sw/lib/gtk-2.0:/run/current-system/sw/lib/gtk-3.0 XDG_DATA_DIRS=/nix/store/q29xkbcc56wq1iqwp7qcwjmswywqiv8b-shared-mime-info-2.1/share:/nix/store/00sf5xsg3i6s8ggnflfzanbgv71hl70f-gnome-shell-40.1/share:/nix/store/97y7kws9r7frjk7y6z4ibvgbnzdqd350-gtk+3-3.24.27/share/gsettings-schemas/gtk+3-3.24.27:/nix/store/41aa9xzsbjfgfk710sn5fg4xgzq6j6pc-gsettings-desktop-schemas-40.0/share/gsettings-schemas/gsettings-desktop-schemas-40.0:/nix/store/g33rhgs45y8fdx6cy6ki0qpmvdvpwi9d-gnome-keyring-40.0/share/gsettings-schemas/gnome-keyring-40.0:/nix/store/qpdw6wvg6nyffaxs44yp94l0iq3jg3f3-gcr-3.40.0/share/gsettings-schemas/gcr-3.40.0:/nix/store/liabvc30rxzs4fkk6wv5cglq50wxvjmm-mutter-40.1/share/gsettings-schemas/mutter-40.1:/nix/store/d0lavdiy4jhqi9ih735xh29smjlbjydl-evolution-data-server-3.40.2/share/gsettings-schemas/evolution-data-server-3.40.2:/nix/store/bqcd5zrbbqr1xm62f4qczgwiqshcya1c-gtk4-4.2.1/share/gsettings-schemas/gtk4-4.2.1:/nix/store/nmwscxrmyxsx9mh4jmbqmkpx69pwxcxj-gdm-40.0/share/gsettings-schemas/gdm-40.0:/nix/store/q78bhi0r2f2srrbhpq875zg9gfn8xc6f-gnome-clocks-40.0/share/gsettings-schemas/gnome-clocks-40.0:/nix/store/3yq2ivk5jyx4n31r89s4drkanzviimsm-ibus-1.5.24/share/gsettings-schemas/ibus-1.5.24:/nix/store/590q9zn94bgh0b7wr9a10w3hyzxmh4ab-gnome-settings-daemon-40.0.1/share/gsettings-schemas/gnome-settings-daemon-40.0.1:/nix/store/i047bkk6rrr80968h8znc8r6g1qqx1c8-libgweather-40.0/share/gsettings-schemas/libgweather-40.0:/nix/store/w72h31n364ckzfaa9xn0fcrq06vy16wc-libnma-1.8.30/share/gsettings-schemas/libnma-1.8.30:/nix/store/00sf5xsg3i6s8ggnflfzanbgv71hl70f-gnome-shell-40.1/share/gsettings-schemas/gnome-shell-40.1:/nix/store/97y7kws9r7frjk7y6z4ibvgbnzdqd350-gtk+3-3.24.27/share:/nix/store/97za2120lnkx0n5vdpk22ij54y8mm22h-cups-2.3.3/share:/nix/store/qpdw6wvg6nyffaxs44yp94l0iq3jg3f3-gcr-3.40.0/share:/nix/store/bqcd5zrbbqr1xm62f4qczgwiqshcya1c-gtk4-4.2.1/share:/nix/store/fnc10mb9f58fipvlm3i69l3f8c2rmw5z-adwaita-icon-theme-40.1.1/share:/nix/store/n0snbh1y2g99grfpi7wf4r9lp6wacp62-hicolor-icon-theme-0.17/share:/nix/store/0bnqia6yjdypx66pc4phj0bkwd4l6q9c-gnome-bluetooth-3.34.5/share:/nix/store/q78bhi0r2f2srrbhpq875zg9gfn8xc6f-gnome-clocks-40.0/share:/nix/store/3yq2ivk5jyx4n31r89s4drkanzviimsm-ibus-1.5.24/share:/nix/store/94l6fyhfav1lss5b9s1f2ss7hkhq7pjn-desktops/share:/home/sei40kr/.nix-profile/share:/etc/profiles/per-user/sei40kr/share:/nix/var/nix/profiles/default/share:/run/current-system/sw/share:/nix/store/17s1r7x7w93lsvhjkwa3d5sfr545fznd-gnome-session-40.1.1/share:/nix/store/41aa9xzsbjfgfk710sn5fg4xgzq6j6pc-gsettings-desktop-schemas-40.0/share/gsettings-schemas/gsettings-desktop-schemas-40.0:/nix/store/97y7kws9r7frjk7y6z4ibvgbnzdqd350-gtk+3-3.24.27/share/gsettings-schemas/gtk+3-3.24.27:/nix/store/590q9zn94bgh0b7wr9a10w3hyzxmh4ab-gnome-settings-daemon-40.0.1/share/gsettings-schemas/gnome-settings-daemon-40.0.1:/nix/store/17s1r7x7w93lsvhjkwa3d5sfr545fznd-gnome-session-40.1.1/share/gsettings-schemas/gnome-session-40.1.1:/nix/store/00sf5xsg3i6s8ggnflfzanbgv71hl70f-gnome-shell-40.1/share:/nix/store/17s1r7x7w93lsvhjkwa3d5sfr545fznd-gnome-session-40.1.1/share:/nix/store/41aa9xzsbjfgfk710sn5fg4xgzq6j6pc-gsettings-desktop-schemas-40.0/share/gsettings-schemas/gsettings-desktop-schemas-40.0:/nix/store/97y7kws9r7frjk7y6z4ibvgbnzdqd350-gtk+3-3.24.27/share/gsettings-schemas/gtk+3-3.24.27:/nix/store/590q9zn94bgh0b7wr9a10w3hyzxmh4ab-gnome-settings-daemon-40.0.1/share/gsettings-schemas/gnome-settings-daemon-40.0.1:/nix/store/17s1r7x7w93lsvhjkwa3d5sfr545fznd-gnome-session-40.1.1/share/gsettings-schemas/gnome-session-40.1.1:/nix/store/00sf5xsg3i6s8ggnflfzanbgv71hl70f-gnome-shell-40.1/share GI_TYPELIB_PATH=/nix/store/97y7kws9r7frjk7y6z4ibvgbnzdqd350-gtk+3-3.24.27/lib/girepository-1.0:/nix/store/wx2kqalxzqhax1xfhjnnyr3fvd8m1ibm-librsvg-2.50.6/lib/girepository-1.0:/nix/store/41aa9xzsbjfgfk710sn5fg4xgzq6j6pc-gsettings-desktop-schemas-40.0/lib/girepository-1.0:/nix/store/gx2gg5xq45fzyykyxbv8xyv2ci3zpn49-atk-2.36.0/lib/girepository-1.0:/nix/store/ahk5g9mdra2vqb3nk8v39pijsb4hjycs-gdk-pixbuf-2.42.6/lib/girepository-1.0:/nix/store/azw8ixqngmrlaln4309fsw8ps0ckmz37-harfbuzz-2.8.1/lib/girepository-1.0:/nix/store/rywq4m4ad9gslv4r41mzyply6yal234m-pango-1.48.4/lib/girepository-1.0:/nix/store/qpdw6wvg6nyffaxs44yp94l0iq3jg3f3-gcr-3.40.0/lib/girepository-1.0:/nix/store/6qfs4c9l69kkmpkslz4yw0l0p7hmzar1-accountsservice-0.6.55/lib/girepository-1.0:/nix/store/gkq59s1z3f2ls09cwwzhv53cqnmq0416-libsecret-0.20.4/lib/girepository-1.0:/nix/store/7w7s5n0hxfjr6lxxpr6lzprhfzm9i8hl-polkit-0.118/lib/girepository-1.0:/nix/store/5vpskk2jxy3iicy30w5qy7a5m11fgxcg-networkmanager-1.30.4/lib/girepository-1.0:/nix/store/g2dksmm93fd0yazb60wam4fx7qiy0am0-json-glib-1.6.2/lib/girepository-1.0:/nix/store/z6gxbwzya2k24fs7qhrbc5ffjd82vw1x-graphene-1.10.6/lib/girepository-1.0:/nix/store/n9vw2c3i62rwpwa5p97an116nn66j4wz-libical-3.0.10/lib/girepository-1.0:/nix/store/7rfv5b6626vyy671i44r710nysammfqh-libsoup-2.72.0/lib/girepository-1.0:/nix/store/d0lavdiy4jhqi9ih735xh29smjlbjydl-evolution-data-server-3.40.2/lib/girepository-1.0:/nix/store/bqcd5zrbbqr1xm62f4qczgwiqshcya1c-gtk4-4.2.1/lib/girepository-1.0:/nix/store/nmwscxrmyxsx9mh4jmbqmkpx69pwxcxj-gdm-40.0/lib/girepository-1.0:/nix/store/hfv5r4dz09d3y3znw88m3a04pr80iwjp-geoclue-2.5.7/lib/girepository-1.0:/nix/store/0bnqia6yjdypx66pc4phj0bkwd4l6q9c-gnome-bluetooth-3.34.5/lib/girepository-1.0:/nix/store/ac099cg1jgpb5fyp1i1yy6c4jzx0c8kf-at-spi2-core-2.40.1/lib/girepository-1.0:/nix/store/4k5f3m5zjnivhnwrdmig8b8ggklp1270-upower-0.99.11/lib/girepository-1.0:/nix/store/3yq2ivk5jyx4n31r89s4drkanzviimsm-ibus-1.5.24/lib/girepository-1.0:/nix/store/9j2qngbhlsqr9in504snbcwxkbry1iiw-gnome-desktop-40.1/lib/girepository-1.0:/nix/store/xkz01kz5namrc5q617ard9vz7pxk6h15-gobject-introspection-1.68.0/lib/girepository-1.0:/nix/store/7ywx7iqg40m0qcm2a4jqbqr71hx6kq71-gstreamer-1.18.4/lib/girepository-1.0:/nix/store/gnkyaz0bp4ppgfh69gp9acnz6dxinpba-gst-plugins-base-1.18.4/lib/girepository-1.0:/nix/store/i047bkk6rrr80968h8znc8r6g1qqx1c8-libgweather-40.0/lib/girepository-1.0:/nix/store/w72h31n364ckzfaa9xn0fcrq06vy16wc-libnma-1.8.30/lib/girepository-1.0:/nix/store/24bd8pw7ajbbag6f719v0q3z053034xv-gnome-autoar-0.3.2/lib/girepository-1.0 XDG_SESSION_DESKTOP=gnome GIO_EXTRA_MODULES=/nix/store/w5jii7aib2ysjcbaj7fcc1g6h38sq5xz-glib-networking-2.68.1/lib/gio/modules:/nix/store/wpvj3wjm1kzxygnclsybdx5c44wld8h5-dconf-0.40.0-lib/lib/gio/modules:/nix/store/w5jii7aib2ysjcbaj7fcc1g6h38sq5xz-glib-networking-2.68.1/lib/gio/modules:/nix/store/wpvj3wjm1kzxygnclsybdx5c44wld8h5-dconf-0.40.0-lib/lib/gio/modules GJS_DEBUG_OUTPUT=stderr TERMINFO_DIRS=/home/sei40kr/.nix-profile/share/terminfo:/etc/profiles/per-user/sei40kr/share/terminfo:/nix/var/nix/profiles/default/share/terminfo:/run/current-system/sw/share/terminfo GDK_PIXBUF_MODULE_FILE=/nix/store/wx2kqalxzqhax1xfhjnnyr3fvd8m1ibm-librsvg-2.50.6/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache QT_PLUGIN_PATH=/home/sei40kr/.nix-profile/lib/qt4/plugins:/home/sei40kr/.nix-profile/lib/kde4/plugins:/etc/profiles/per-user/sei40kr/lib/qt4/plugins:/etc/profiles/per-user/sei40kr/lib/kde4/plugins:/nix/var/nix/profiles/default/lib/qt4/plugins:/nix/var/nix/profiles/default/lib/kde4/plugins:/run/current-system/sw/lib/qt4/plugins:/run/current-system/sw/lib/kde4/plugins TERM=alacritty SHELL=/run/current-system/sw/bin/zsh XDG_SESSION_CLASS=user GNOME_SETUP_DISPLAY=:1 XDG_CURRENT_DESKTOP=GNOME SHLVL=1 LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive XDG_DESKTOP_PORTAL_DIR=/nix/store/6pa52gc42pkdmqyh9a8i2ihgg6f5g0l6-xdg-portals/share/xdg-desktop-portal/portals GDMSESSION=gnome LOGNAME=sei40kr DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus XDG_RUNTIME_DIR=/run/user/1000 XAUTHORITY=/run/user/1000/.mutter-Xwaylandauth.0K2G60 XDG_CONFIG_DIRS=/home/sei40kr/.nix-profile/etc/xdg:/etc/profiles/per-user/sei40kr/etc/xdg:/nix/var/nix/profiles/default/etc/xdg:/run/current-system/sw/etc/xdg:/nix/store/590q9zn94bgh0b7wr9a10w3hyzxmh4ab-gnome-settings-daemon-40.0.1/etc/xdg:/nix/store/590q9zn94bgh0b7wr9a10w3hyzxmh4ab-gnome-settings-daemon-40.0.1/etc/xdg PATH=/run/wrappers/bin:/home/sei40kr/.nix-profile/bin:/etc/profiles/per-user/sei40kr/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin INFOPATH=/home/sei40kr/.nix-profile/info:/home/sei40kr/.nix-profile/share/info:/etc/profiles/per-user/sei40kr/info:/etc/profiles/per-user/sei40kr/share/info:/nix/var/nix/profiles/default/info:/nix/var/nix/profiles/default/share/info:/run/current-system/sw/info:/run/current-system/sw/share/info GDM_X_SERVER_EXTRA_ARGS=-config /nix/store/vwn673c2cir2hqrgkcda5kg9pll5iy1q-xserver.conf -xkbdir /nix/store/lnr53k4fkc2kvilwj428r3z7n3a1w3h4-xkeyboard-config-2.33/etc/X11/xkb -logfile /dev/null -nolisten tcp GJS_DEBUG_TOPICS=JS ERROR;JS LOG GST_PLUGIN_SYSTEM_PATH_1_0=/nix/store/i9q8bj3ghrjnqmhignd6srxqx6m2vrhf-pipewire-0.3.30-lib/lib/gstreamer-1.0:/nix/store/7ywx7iqg40m0qcm2a4jqbqr71hx6kq71-gstreamer-1.18.4/lib/gstreamer-1.0:/nix/store/gnkyaz0bp4ppgfh69gp9acnz6dxinpba-gst-plugins-base-1.18.4/lib/gstreamer-1.0:/nix/store/lf393q0rjkd8i0ci9nzc6yrk8jghc6f3-gst-plugins-good-1.18.4/lib/gstreamer-1.0:/nix/store/i9q8bj3ghrjnqmhignd6srxqx6m2vrhf-pipewire-0.3.30-lib/lib/gstreamer-1.0:/nix/store/7ywx7iqg40m0qcm2a4jqbqr71hx6kq71-gstreamer-1.18.4/lib/gstreamer-1.0:/nix/store/gnkyaz0bp4ppgfh69gp9acnz6dxinpba-gst-plugins-base-1.18.4/lib/gstreamer-1.0:/nix/store/lf393q0rjkd8i0ci9nzc6yrk8jghc6f3-gst-plugins-good-1.18.4/lib/gstreamer-1.0 SESSION_MANAGER=local/nixos:@/tmp/.ICE-unix/315074,unix/nixos:/tmp/.ICE-unix/315074 XCURSOR_PATH=/home/sei40kr/.icons:/home/sei40kr/.local/share/icons:/home/sei40kr/.nix-profile/share/icons:/home/sei40kr/.nix-profile/share/pixmaps:/etc/profiles/per-user/sei40kr/share/icons:/etc/profiles/per-user/sei40kr/share/pixmaps:/nix/var/nix/profiles/default/share/icons:/nix/var/nix/profiles/default/share/pixmaps:/run/current-system/sw/share/icons:/run/current-system/sw/share/pixmaps _=/run/current-system/sw/bin/env ```

And then I noticed none of GTK_IM_MODULE, QT_IM_MODULE was set. Wayland session doesn't read /etc/profile, so we may need those environment variables in /etc/environment.

Thank you.

sei40kr commented 3 years ago

I put this in my configuration:

{
    # Wayland sesion doesn't read environment.variables
    environment.sessionVariables = {
      GTK_IM_MODULE = "fcitx";
      QT_IM_MODULE = "fcitx";
      XMODIFIERS = "@im=fcitx";
    };
}

and confirmed those variables in set in GNOME session. (same way as above) But it's still not working. There probably exists another cause.

jansol commented 3 years ago

It's also not working for me in Plasma5 / Wayland, even if I set those env variables.

sei40kr commented 3 years ago

Exporting NIX_USER_PROFILE_DIR and NIX_PROFILES worked for me:

sh-4.4$ export NIX_USER_PROFILE_DIR="/nix/var/nix/profiles/per-user/$USER"
sh-4.4$ export NIX_PROFILES="/run/current-system/sw /nix/var/nix/profiles/default /etc/profiles/per-user/$USER $HOME/.nix-profile"
sh-4.4$ google-chrome-stable

I think those variables have nothing to do with Fcitx 5, but somehow, it works :thinking:

sei40kr commented 3 years ago

https://github.com/NixOS/nixpkgs/blob/42cadf5a768c81d912adba037d30c39d09f326c7/pkgs/development/libraries/gtk/patches/3.0-immodules.cache.patch#L8

Maybe this is related.

sei40kr commented 3 years ago
    environment.sessionVariables = {
      NIX_PROFILES =
        "${concatStringsSep " " (reverseList config.environment.profiles)}";
      GTK_IM_MODULE = "fcitx";
      QT_IM_MODULE = "fcitx";
      XMODIFIERS = "@im=fcitx";
    };

This works great for me!

  1. Use environment.sessionVariables to export GTK_IM_MODULE, QT_IM_MODULE, XMODIFIERS because Wayland session doesn't read set-environment
  2. Export NIX_PROFILES, NIX_USER_PROFILE_DIRS, and other Nix basic variables in pam-environment
Vonfry commented 3 years ago

Please check https://github.com/fcitx/fcitx5/issues/292#issuecomment-864396920.
Wayland support is in progress and you may need xwayland now.

On 2021年7月8日 at 06:19:20, Seong Yong-ju @.**@.)) wrote:

environment.sessionVariables = { NIX_PROFILES = "${concatStringsSep " " (reverseList config.environment.profiles)}"; GTK_IM_MODULE = "fcitx"; QT_IM_MODULE = "fcitx"; XMODIFIERS = @.***=fcitx"; };

This works great for me!

Use environment.sessionVariables to export GTK_IM_MODULE, QT_IM_MODULE, XMODIFIERS because Wayland session doesn't read set-environment Export NIX_PROFILES, NIX_USER_PROFILE_DIRS, and other Nix basic variables in pam-environment

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub(https://github.com/NixOS/nixpkgs/issues/129442#issuecomment-875972207), or unsubscribe(https://github.com/notifications/unsubscribe-auth/AA2BI77XIZ7YSRKDHP5LNDLTWTHGRANCNFSM474XCIKA).

jansol commented 3 years ago

Setting those variables to environment.sessionVariables does indeed seem to work. The Fcitx5 module in NixOS already sets the *_IM_MODULE variables... but it does that using environment.variables, which should probably be changed. Does environment.sessionVariables work in X11 environments? Not sure what the right place for setting NIX_PROFILES would be but I'm pretty sure it's not in the Fcitx5 module.

Vonfry commented 3 years ago

I'd like to let wayland use set-environment rather than move them into sessionvariables because there are other variables besides ones for inputmethods. Is there a startup script for wayland like xprofile?

sei40kr commented 3 years ago

@Vonfry

Is there a startup script for wayland like xprofile?

Basically, no.

We have 2 ways to set environment for Wayland session:

  1. Write in pam-environment & let display manager read it (we should consider some people use no display manager)
  2. Make a wrapper for desktop manager (just like Sway's extraSessionCommands)
Vonfry commented 3 years ago

I perfer to make a wrapper.

Currently, x11 is also worked with a wrapper. You can check xsessionWrapper in <nixpkgs/nixos/modules/services/x11/display-manager/default.nix>. Then desktop-manager is also worked with a wrapper in services.xserver.desktopManager.session.start (<nixpkgs/nixos/modules/services/x11/desktop-managers/default.nix>).

Seong Yong-ju @.***> writes:

@Vonfry

Is there a startup script for wayland like xprofile?

Basically, no.

We have 2 ways to set environment for Wayland session:

  1. Write in pam-environment & let display manager read it
  2. Make a wrapper for desktop manager (just like extraSessionCommands in Sway)
sagehane commented 2 years ago

Sorry if this is entirely a different issue (it probably is), but I can't even figure out how to get fcitx5 to recognize fcitx5-mozc. Using fcitx5-configtool doesn't even show mozc for me:

image

I do have the following, so I don't quite get how this could happen.

{
  i18n.inputMethod = {
    enabled = "fcitx5";
    fcitx5.addons = with pkgs; [ fcitx5-mozc ];
  };
}

I'm on:

$ nixos-version
22.05pre352272.c5051e2b5fe (Quokka)
Vonfry commented 2 years ago

You should search mozc instead of japanese, because the name of mozc doesn't involve japanese. By the way, you may also uncheck "Only Show Current Language".

Sage Hane @.***> writes:

Sorry if this is entirely a different issue (it probably is), but I can't even figure out how to get fcitx5 to recognize fcitx5-mozc. Using fcitx5-configtools doesn't even show mozc for me:

image

I do have the following, so I don't quite get how this could happen.

{ i18n.inputMethod = { enabled = "fcitx5"; fcitx5.addons = with pkgs; [ fcitx5-mozc ]; }; }

I'm on:

$ nixos-version 22.05pre352272.c5051e2b5fe (Quokka)

— Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you were mentioned.

sagehane commented 2 years ago

I've tried that too. The issue seems to be that the wrong Addon Config Dir was being read, so I opened an issue at https://github.com/NixOS/nixpkgs/issues/160437.

I do find it weird that nobody else other than me seems to have encountered it. I wonder if I'm doing something wrong.

sei40kr commented 2 years ago

@sagehane If you can't find Mozc by searching mozc, then restart Fcitx5 daemon by running

fcitx5 -r

and try again.

If this won't fix your issue, it's entirely a different issue.

sagehane commented 2 years ago

Yep, I've tried plenty of stuff, including manually doing fcitx-remote -s, it's a different issue from my understanding. Sorry to bother.

billksun commented 1 year ago
    environment.sessionVariables = {
      NIX_PROFILES =
        "${concatStringsSep " " (reverseList config.environment.profiles)}";
      GTK_IM_MODULE = "fcitx";
      QT_IM_MODULE = "fcitx";
      XMODIFIERS = "@im=fcitx";
    };

This works great for me!

1. Use `environment.sessionVariables` to export `GTK_IM_MODULE`, `QT_IM_MODULE`, `XMODIFIERS` because Wayland session doesn't read `set-environment`

2. Export `NIX_PROFILES`, `NIX_USER_PROFILE_DIRS`, and other Nix basic variables in `pam-environment`

I just hit this problem myself after switching to Wayland on KDE Plasma. Thanks for this snippet! Until a proper solution for Wayland is developed, I will be using this configuration workaround.

breakds commented 4 months ago
    environment.sessionVariables = {
      NIX_PROFILES =
        "${concatStringsSep " " (reverseList config.environment.profiles)}";
      GTK_IM_MODULE = "fcitx";
      QT_IM_MODULE = "fcitx";
      XMODIFIERS = "@im=fcitx";
    };

This works great for me!

  1. Use environment.sessionVariables to export GTK_IM_MODULE, QT_IM_MODULE, XMODIFIERS because Wayland session doesn't read set-environment
  2. Export NIX_PROFILES, NIX_USER_PROFILE_DIRS, and other Nix basic variables in pam-environment

Saved my day! Thanks!

jansol commented 4 months ago

FWIW with the plasma6 module you don't need to set any environment variables for Fcitx5 to work. In fact it will yell at you if you do.

HOWEVER if you are switching over from an older version or from X11 you should make sure to delete all KDE and Fcitx-related files and subdirectories from your ~/.config as those probably still try to launch the X11 version of Fcitx5

jansol commented 4 months ago

And you'll also need to enable the Fcitx 5 virtual keyboard in Plasma settings under Keyboard > Virtual Keyboard (technically you should enable Fcitx 5 Wayland Launcher but it seems to revert to Fcitx 5 afterwards and still work fine: image