I’m snapping a PyQt application which uses file picker dialogs. I connected the home interface but all the file pickers start in $HOME by default which is $SNAP_USER_DATA instead of the “real” home folder. What’s worse is that file picker shortcuts for Home, Desktop, Downloads are also relative to $SNAP_USER_DATA, whereas I want them to point to user’s $HOME.
I see two options here but neither seems like a good idea:
- Change my application code for snaps only to make file pickers start in the real home (but I’d need to get the real home which might not be so easy).
- Hardcode $HOME to the real home in my launcher script - this can work but I’m not sure if it’s a good idea since all other files that possibly should to be in $SNAP_USER_DATA are going to be in $HOME.
Anyone come across this problem?
I don’t think there is a good answer at the moment.
If you use classic confinement, then your snap should see the real value of
$HOME. But this has the downside of requiring the user to pass extra flags to
snap install, and requires a bit more care to make the snap distro version independent.
I have been looking into using getting xdg-desktop-portal working with snaps, and while I got a proof of concept demo working it is far from ready for deployment. Under this model, things would behave a bit differently:
- you would no longer have to connect to the
- assuming the appropriate modules are loaded, the Qt file picker API would ask a process outside of the confinement sandbox to display the dialog box, and the file the user chooses would be made available at a path your app can read/write.
Since the file picker is out of process, it doesn’t matter what
$HOME is inside the sandbox.
Thanks very much for your answer. My app requires strict confinement, so the first option won’t work.
And I looked into the link you sent and it looks promising, but like you said that’s not going to fly either, at least for the moment.
So for now I think I’ll have to set $HOME to real home in my launcher script and give up the versioning that $SNAP_USER_DATA provides.
I’ll keep an eye on the xdg-desktop-portal progress.