xdg-desktop-portal
xdg-desktop-portal copied to clipboard
OpenDirectory opens parent directory when passing directory descriptor
#!/bin/sh
exec 3< /home
gdbus call --session \
--dest org.freedesktop.portal.Desktop \
--object-path /org/freedesktop/portal/desktop \
--method org.freedesktop.portal.OpenURI.OpenDirectory \
--timeout 30 \
"" "3" {}
results in

Using OpenFile with a directory fd works fine. This might be working as intended, could do with clarification in the docs.
I believe this is working as intended. I think the design is:
OpenFileopens the given filesystem object itself: a directory in a file manager, or a file in the associated program (e.g. a text file in a text editor)OpenDirectoryopens the directory containing the given filesystem object in a file manager, with a selection/highlight placed on the filesystem object itself (in your screenshot you'll see that/homeis selected)
Perhaps you could propose a documentation clarification in a MR that would have given you a better idea of how this works?
Similarly, if you change your reproducer to use an existing file instead of an existing directory, for example exec 3< /etc/passwd, you should see a file manager opened on /etc, with a highlight on passwd.
In the file case, I hope it's obvious that this is the only thing that would be correct, because /etc/passwd isn't a directory; but then the handling you observed for /home is consistent with that.