lxqt / xdg-desktop-portal-lxqt

A backend implementation for xdg-desktop-portal
GNU Lesser General Public License v2.1
20 stars 8 forks source link

Update README.md #25

Closed stefonarch closed 8 months ago

stefonarch commented 8 months ago

Any objections? Related https://github.com/lxqt/xdg-desktop-portal-lxqt/issues/23

tsujan commented 8 months ago

None from me if you know that it works (I don't use portals).

q234rty commented 8 months ago

TL;DR: We want

hash dbus-update-activation-environment 2>/dev/null && \
     dbus-update-activation-environment --systemd XDG_CURRENT_DESKTOP=LXQt

in startlxqt.

I don't think writing a config file into ~/.config/xdg-desktop-portal/lxqt-portals.conf currently works under a lxqt session as started in https://github.com/lxqt/lxqt-session/blob/master/startlxqt.in

The issue is, xdg-desktop-portal does not "know" it's a lxqt session, so it won't read lxqt-portals.conf. The portal relies on the env var XDG_CURRENT_DESKTOP for that, and while the startlxqt script exports said env var, xdg-desktop-portal is usually started via dbus activation, which does not use the same environment.

The command mentioned above tries to update the dbus activation environment as well.

As a workaround before said change is released, one can use ~/.config/xdg-desktop-portal/portals.conf instead, as x-d-p reads that when XDG_CURRENT_DESKTOP is not set.

Edit: Apparently https://github.com/lxqt/lxqt-session/blob/a7e61a3726758b5503b38083c43c897a3d4143be/lxqt-session/src/sessionapplication.cpp#L347 imports the whole env, it's probably a race between that and xdg-desktop-portal being started via activation then.

Edit 2: Qt has portal integration enabled by default in https://invent.kde.org/qt/qt/qtbase/-/blob/kde/5.15/src/platformsupport/services/genericunix/qgenericunixservices.cpp#L389 , as lxqt-session is itself a QApplication, this triggers the dbus activation of xdg-desktop-portal, breaking the env vars of said process since SessionApplication::updateDBusEnvironment hasn't yet been called . We need to set QT_NO_XDG_DESKTOP_PORTAL=1 before creating the QApplication and remember to unset it after the dbus env vars are setup.