Bug 460238 - In a xorg session xdg-desktop-portal is started without $XDG_CURRENT_DESKTOP in environment
Summary: In a xorg session xdg-desktop-portal is started without $XDG_CURRENT_DESKTOP ...
Status: RESOLVED DUPLICATE of bug 458865
Alias: None
Product: xdg-desktop-portal-kde
Classification: Plasma
Component: general (show other bugs)
Version: 5.25.5
Platform: Fedora RPMs Linux
: NOR major
Target Milestone: ---
Assignee: Plasma Bugs List
Depends on:
Reported: 2022-10-11 10:54 UTC by Alessandro Astone
Modified: 2022-10-11 12:28 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Note You need to log in before you can comment on or make changes to this bug.
Description Alessandro Astone 2022-10-11 10:54:25 UTC
Preface: reporting under xdg-desktop-portal-kde despite this being of wider scope, and probably not related to the kde portal at all...

When multiple portals are installed, xdg-desktop-portal picks the best one for the current session based on $XDG_CURRENT_DESKTOP. But in a Plasma X11 session xdg-desktop-portal.service is started without such variable in its environment. So the portal falls back to choosing the implementation with alphabetical order, and gnome wins.

This only happens in Plasma X11, the variable (alongside the other XDG and /etc/profile.d/ variables) is picked up in a Plasma Wayland session. This happens both with and without systemdBoot.

xdg-desktop-portal-gtk is the only service that gets started with all my environment variables, where xdg-desktop-portal, xdg-desktop-portal-gnome, plasma-xdg-desktop-portal-kde are not

1. Install both xdg-desktop-portal-kde and xdg-desktop-portal-gnome
2. Fresh reboot (log-out and log-in causes a different behaviour...)
2. Log into a Plasma X11 session

`xargs -0 -L1 -a /proc/$(pidof xdg-desktop-portal)/environ` does not contain XDG_CURRENT_DESKTOP.
A visible effect, for example, is that in flatpaks the file picker is GTK
Another important effect is that when an application is started as a result of opening a file from inside a flatpak, it will inherit an incomplete environment from xdg-desktop-portal. For example, opening a PDF from Telegram flatpak will make Okular not use the Breeze theme, and other applications may have other issues depending on what XDG environment variables they expect.

More user environment variables are imported when starting xdg-desktop-portal, so that the correct portal implementation is picked, and a complete environment is used when forking.

Linux/KDE Plasma: Fedora 36 KDE
(available in About System)
KDE Plasma Version: 5.25.5
KDE Frameworks Version: 5.98.0
Qt Version: 5.15.6

As far as I understand xdg-desktop-portal is dbus-activated and its environment variables depend on the process that activates it. In my case that process seems to be early-started, before (who?) sets XDG_CURRENT_DESKTOP and friends.
Comment 1 Antonio Rojas 2022-10-11 12:28:38 UTC

*** This bug has been marked as a duplicate of bug 458865 ***