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

OpenDirectory opens parent directory when passing directory descriptor

Open LunNova opened this issue 3 years ago • 2 comments
trafficstars

#!/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

image

Using OpenFile with a directory fd works fine. This might be working as intended, could do with clarification in the docs.

LunNova avatar Dec 26 '21 18:12 LunNova

I believe this is working as intended. I think the design is:

  • OpenFile opens 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)
  • OpenDirectory opens 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 /home is selected)

Perhaps you could propose a documentation clarification in a MR that would have given you a better idea of how this works?

smcv avatar Dec 26 '21 21:12 smcv

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.

smcv avatar Dec 26 '21 21:12 smcv