Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue] GTK_IM_Module set? #222

Closed
Iridule opened this issue Jan 31, 2024 · 20 comments
Closed

[Issue] GTK_IM_Module set? #222

Iridule opened this issue Jan 31, 2024 · 20 comments

Comments

@Iridule
Copy link

Iridule commented Jan 31, 2024

I get a Wayland diagnostic notification saying "GTK_IM_MODULE being set and Wayland input method frontend is working. It is recommended to unset GTK_IM_MODULE."

I've tried adding the lines below to ~/.bash_profile but same notification appears after login.
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx

@clsty
Copy link
Collaborator

clsty commented Jan 31, 2024

I don't know but maybe you're using ibus and not fcitx5?

I've searched It is recommended to unset GTK_IM_MODULE on internet but there's no matching result.

@Iridule
Copy link
Author

Iridule commented Feb 1, 2024

I'm at a loss on what to do or how it impacts my setup. I've noticed some times of an app like vlc is open the keyboard won't work and the right mouse button doesn't work...not sure if these things are related to the diagnostic message or not

@clsty
Copy link
Collaborator

clsty commented Feb 1, 2024

I guess you need to install the input method first, since they are not listed in scriptdata/dependencies.txt:

sudo pacman -S fcitx5{,-{qt,lua,configtool,gtk}} ibus

If this solves your problem, then I think those pkgs should be added to scriptdata/dependencies.txt too.

Or, if you don't need input method, you can just remove the related lines in ~/.config/hypr/env.conf and ~/.config/hypr/execs.conf. Also in ~/.bash_profile as you said.

@Iridule
Copy link
Author

Iridule commented Feb 1, 2024

@clsty I installed those packages yet the issue persists....
IMG_20240131_211013397~2

@clsty
Copy link
Collaborator

clsty commented Feb 1, 2024

From https://fcitx-im.org/wiki/Using_Fcitx_5_on_Wayland:

For GTK_IM_MODULE, as for now, the modern Gtk 3/4 application should be able to use text-input-v3 which is supported almost by every compositor, except weston. There are a few different options in terms of setting the value of GTK_IM_MODULE. When it is unset, the Gtk built-in Wayland im module will be used for Gtk3 and Gtk4. While you can also enforce it by doing GTK_IM_MODULE=wayland, remember it will be also picked up by Gtk2. Setting GTK_IM_MODULE=fcitx can still work, and it is necessary if your compositor does not support Wayland input method frontend.

The information you met with comes from here:

Click to expand
    auto *gtk = getenv("GTK_IM_MODULE");
    auto *qt = getenv("QT_IM_MODULE");
    std::string gtkIM = gtk ? gtk : "";
    std::string qtIM = qt ? qt : "";


    std::vector<std::string> messages;
    const auto desktop = getDesktopType();
    if (desktop == DesktopType::KDE5) {
        if (!isWaylandIM) {
            sendMessage(
                "wayland-diagnose-kde",
                _("Fcitx should be launched by KWin under KDE Wayland in order "
                  "to use Wayland input method frontend. This can improve the "
                  "experience when using Fcitx on Wayland. To "
                  "configure this, you need to go to \"System Settings\" -> "
                  "\"Virtual "
                  "keyboard\" and select \"Fcitx 5\" from it. You may also "
                  "need to disable tools that launches input method, such as "
                  "imsettings on Fedora, or im-config on Debian/Ubuntu. For "
                  "more details see "
                  "https://fcitx-im.org/wiki/"
                  "Using_Fcitx_5_on_Wayland#KDE_Plasma"));
        } else if (!gtkIM.empty() || !qtIM.empty()) {
            sendMessage("wayland-diagnose-kde",
                        _("Detect GTK_IM_MODULE and QT_IM_MODULE being set and "
                          "Wayland Input method frontend is working. It is "
                          "recommended to unset GTK_IM_MODULE and QT_IM_MODULE "
                          "and use Wayland input method frontend instead. For "
                          "more details see "
                          "https://fcitx-im.org/wiki/"
                          "Using_Fcitx_5_on_Wayland#KDE_Plasma"));
        }
    } else if (desktop == DesktopType::GNOME) {
        if (instance_->currentUI() != "kimpanel") {
            sendMessage(
                "wayland-diagnose-gnome",
                _("It is recommended to install Input Method Panel GNOME "
                  "Shell Extensions to provide the input method popup. "
                  "https://extensions.gnome.org/extension/261/kimpanel/ "
                  "Otherwise you may not be able to see input method popup "
                  "when typing in GNOME Shell's activities search box. For "
                  "more details "
                  "see "
                  "https://fcitx-im.org/wiki/Using_Fcitx_5_on_Wayland#GNOME"));
        }
    } else {
        // It is not clear whether compositor is supported, only warn if wayland
        // im is being used..
        if (isWaylandIM) {
            // Sway's input popup is not merged.
            if (!gtkIM.empty() && gtkIM != "wayland" &&
                desktop != DesktopType::Sway) {
                messages.push_back(
                    _("Detect GTK_IM_MODULE being set and "
                      "Wayland Input method frontend is working. It is "
                      "recommended to unset GTK_IM_MODULE "
                      "and use Wayland input method frontend instead."));
            }
        }

@clsty
Copy link
Collaborator

clsty commented Feb 1, 2024

I guess you can just remove the GTK_IM_MODULE lines in hyprland's config as I mentioned before, or change its value to wayland instead of fcitx.

Still, it's kinda weird because I'm using fcitx5 myself and I didn't met with such diagnose notification.

And there's another possibility that fcitx5 think you're in sway, not hyprland.

Notice that:

    } else {
        // It is not clear whether compositor is supported, only warn if wayland
        // im is being used..
        if (isWaylandIM) {
            // Sway's input popup is not merged.
            if (!gtkIM.empty() && gtkIM != "wayland" &&
                desktop != DesktopType::Sway) {
                messages.push_back(
                    _("Detect GTK_IM_MODULE being set and "
                      "Wayland Input method frontend is working. It is "
                      "recommended to unset GTK_IM_MODULE "
                      "and use Wayland input method frontend instead."));
            }
        }

Which means that, to pop up this message you saw, the value of $GTK_IM_MODULE is not empty nor wayland, and the DesktopType is Sway.

EDIT: Sorry for mistake, it's desktop != DesktopType::Sway, which means the DesktopType is NOT Sway.

@clsty
Copy link
Collaborator

clsty commented Feb 1, 2024

As for DesktopType, it's here:

Click to expand
static inline DesktopType getDesktopType() {
    std::string desktop;
    // new standard
    auto *desktopEnv = getenv("XDG_CURRENT_DESKTOP");
    if (desktopEnv) {
        desktop = desktopEnv;
    }
    if (desktop.empty()) {
        // old standard, guaranteed by display manager.
        desktopEnv = getenv("DESKTOP_SESSION");
        if (desktopEnv) {
            desktop = desktopEnv;
        }
    }


    for (auto &c : desktop) {
        c = charutils::tolower(c);
    }
    auto desktops =
        stringutils::split(desktop, ":", stringutils::SplitBehavior::SkipEmpty);
    for (const auto &desktop : desktops) {
        if (desktop == "kde") {
            auto *version = getenv("KDE_SESSION_VERSION");
            auto versionInt = 0;
            if (version) {
                try {
                    versionInt = std::stoi(version);
                } catch (...) {
                }
            }
            if (versionInt == 4) {
                return DesktopType::KDE4;
            }
            return DesktopType::KDE5;
        } else if (desktop == "x-cinnamon") {
            return DesktopType::Cinnamon;
        } else if (desktop == "lxde") {
            return DesktopType::LXDE;
        } else if (desktop == "mate") {
            return DesktopType::MATE;
        } else if (desktop == "gnome") {
            return DesktopType::GNOME;
        } else if (desktop == "xfce") {
            return DesktopType::XFCE;
        } else if (desktop == "deepin") {
            return DesktopType::DEEPIN;
        } else if (desktop == "ukui") {
            return DesktopType::UKUI;
        } else if (desktop == "sway") {
            return DesktopType::Sway;
        }
    }
    return DesktopType::Unknown;
}


static inline bool isKDE() {
    static const DesktopType desktop = getDesktopType();
    return desktop == DesktopType::KDE4 || desktop == DesktopType::KDE5;
}

@clsty
Copy link
Collaborator

clsty commented Feb 1, 2024

Please run:

echo "1=$XDG_CURRENT_DESKTOP"
echo "2=$DESKTOP_SESSION"

and paste your output.

@Iridule
Copy link
Author

Iridule commented Feb 1, 2024

I tried to add the values below to ~/.bash_profile
But no change...I will try to remove the lines in Hyprland config...I suppose I could just dismiss the message as well yet that doesn't solve the problem.

export GTK_IM_MODULE=
export QT_IM_MODULE=wayland
export XMODIFIERS=@im=wayland

@clsty
Copy link
Collaborator

clsty commented Feb 1, 2024

Well... Firstly, although I don't know why, I hardly see people add these lines into ~/.bash_profile when using hyprland, so I recommend you to just remove all related lines there.
Better use ~/.config/hypr/env.conf to edit environment variables instead.

Secondly, you mentioned there're vlc and keyboard problems so I guess $XDG_CURRENT_DESKTOP may matters. Somewhere in your setup may be broken.

@Iridule
Copy link
Author

Iridule commented Feb 1, 2024

Please run:

echo "1=$XDG_CURRENT_DESKTOP"
echo "2=$DESKTOP_SESSION"

and paste your output.

1=Hyprland 2=hyprland also no mention of fcitx in hyprland.config

@clsty
Copy link
Collaborator

clsty commented Feb 1, 2024

And I forgot to mention that ~/.bash_profile affect your shell, but maybe not other programs, so you need to clear those lines in ~/.bash_profile first before running

echo "1=$XDG_CURRENT_DESKTOP"
echo "2=$DESKTOP_SESSION"

to get the "real" values.

@clsty
Copy link
Collaborator

clsty commented Feb 1, 2024

And there may be xdg-desktop-portal problems. What's your output of

pacman -Q|grep xdg-desktop-portal

?

@Iridule
Copy link
Author

Iridule commented Feb 1, 2024

Echo results are the same here is the additional output...

IMG_20240131_224043817

@clsty
Copy link
Collaborator

clsty commented Feb 1, 2024

Ok, so let me summarize what for now:

Problems

  1. You're using ~/.bash_profile for environment variable.
    It may only affect your shell, not affect some programs, such as fcitx5,
    which would make your $XDG_CURRENT_DESKTOP seems good in shell but actually broken (just a guess, unsure).

  2. You're using different xdg-desktop-portals which will conflict with each others.
    See https://wiki.hyprland.org/Useful-Utilities/Hyprland-desktop-portal/ for details.

Try to resolve

  1. Add the following line to ~/.config/hypr/env.conf:
env = XDG_CURRENT_DESKTOP, Hyprland
env = GTK_IM_MODULE, wayland
  1. Run:
sudo pacman --noconfirm -Rdd xdg-desktop-portal-{gnome,wlr}
yay -S --noconfirm --needed xdg-desktop-portal-hyprland-git qt{5,6}-wayland
  1. Reboot your computer.

@Iridule
Copy link
Author

Iridule commented Feb 1, 2024

Ok desktop portal output 3 has changed to hyprland 1.3.1-2
Other values are the same as my previous post. 3 total listings for pacman -Q|grep xdg-desktop-portal
Also I noticed at the top of the ~/.config/hypr/env.conf file there was a section for input method with all options set to fcitx. I removed the first option and set GTK_IM_MODULE as empty, this got rid of the diagnostic notification from before. Thanks for your help. Though I'm not sure env variable in ~/.config/hypr/env.conf is even needed ? The output is the same without it.
IMG_20240131_234315766

IMG_20240131_234606150

@clsty
Copy link
Collaborator

clsty commented Feb 1, 2024

As I mentioned before, the output is from shell, which might be different from other programs e.g. vlc and fcitx5.

~/.config/hypr/env.conf is recommended for editing environment variables.
I suggest you stop using ~/.bash_profile for such purpose.

@Iridule
Copy link
Author

Iridule commented Feb 1, 2024

@clsty
I was using the bash_profile because it was mentioned here https://fcitx-im.org/wiki/Configure_(Other)
I wasn't aware Hyprland had env config in it's own file. I assumed it would be defined in bash_profile thanks for the clarification.

@Iridule Iridule closed this as completed Feb 1, 2024
@clsty
Copy link
Collaborator

clsty commented Feb 3, 2024

Update: I may have mistaken something.
xdg-desktop-portal-gnome and -kde are conflicting with -hyprland and -wlr before, e.g. hyprwm/Hyprland#2041

But I can't find such description anymore on https://wiki.hyprland.org/Useful-Utilities/Hyprland-desktop-portal/, so I guess they're NOT conflicting anymore due to some updates.

@Iridule
Copy link
Author

Iridule commented Feb 3, 2024

I have not noticed any issue. All seems to work well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants