xdg-desktop-portal icon indicating copy to clipboard operation
xdg-desktop-portal copied to clipboard

Also load portals from XDG_DATA_DIRS

Open andychenbruce opened this issue 10 months ago • 3 comments

Addresses issue #603. The only place it searches for portals is the DATADIR or XDG_DESKTOP_PORTAL_DIR, but if XDG_DESKTOP_PORTAL_DIR is set, then it doesn't read configuration files.

This is a problem because any system that doesn't follow the FHS must set XDG_DESKTOP_PORTAL_DIR for it to find the portals, but then can't load any configuration files which leaves everything broken. A simple solution is to search all the directories in XDG_DATA_DIRS.

andychenbruce avatar Jan 09 '25 20:01 andychenbruce

I really would want to have tests for the configs. With the pytest setup we currently have, we can only test config in $HOME but we could modify things for this test to launch x-d-p in a new mount namespace with /usr/local/share/xdg-desktop-portal etc under our control.

Is that something you could look into?

swick avatar Jan 09 '25 21:01 swick

With the pytest setup we currently have, we can only test config in $HOME but we could modify things for this test to launch x-d-p in a new mount namespace with /usr/local/share/xdg-desktop-portal etc under our control.

If we do this, please only do it as additional test coverage, and not as the only way some other thing gets tested. Linux distributions' autobuilders usually can't create new mount namespaces so this would have to be skipped.

smcv avatar Jan 09 '25 21:01 smcv

Alternative to unshare for testing: introduce environment variables that overwrites the "system" dirs. Should work everywhere then at least.

swick avatar Jan 15 '25 14:01 swick

For reference this is how nix deals with the not loading configuration files problem.

andychenbruce avatar Mar 09 '25 20:03 andychenbruce

Somewhat related; this is what we use in GNU Guix: https://github.com/flatpak/xdg-desktop-portal/pull/1716

apteryks avatar May 17 '25 08:05 apteryks

2 wrongs don't make a right.

hfiguiere avatar May 17 '25 13:05 hfiguiere

Looks like since https://github.com/flatpak/xdg-desktop-portal/pull/1665 has been merged, we can now use XDG_DATA_DIRS instead of (ab)using the XDG_DESKTOP_PORTAL_DIR environment variable, which appears to be catering to the test suite only?

apteryks avatar May 18 '25 03:05 apteryks

Yes, please drop the patch that abuses XDG_DESKTOP_PORTAL_DIR. It's for the test suite only.

swick avatar May 19 '25 09:05 swick

Closing in favor of https://github.com/flatpak/xdg-desktop-portal/pull/1665

swick avatar May 19 '25 09:05 swick