(/usr/libexec/xdg-desktop-portal:55813): xdg-desktop-portal-WARNING **: 09:43:13.147: Failed to create background monitor: Failed to own background monitor D-Bus name
(/usr/libexec/xdg-desktop-portal:55813): xdg-desktop-portal-WARNING **: 09:43:13.147: No skeleton to export
The mechanism that @johnandmegh has noted is the much easier option and is an approach that I’ve been using for my own purposes, however I’ve been looking into a way to invoke the file chooser via command line so that I have a potential toolkit-agnostic way to initiate the a file picker and just in case, thought I’d note what I’ve found here in case it’s of interest.
Edit: I should not that the below is feels more like, as I’ve had trouble so far monitoring for the response in the way I’d expect it and getting an output. I’ll look to update this once I can get a better idea of how this works.
From my investigation, it appears that In theory, it is possible to invoke the file picker from the CLI, however it requires that you do it through D-Bus and the process related to it appears to requires a few steps to do:
You have to send an initial D-Bus call to open the file chooser dialog.
From the first call, you’ll receive a response with an Object Path handle.
Using the Object Path handle, send another D-Bus call to monitor for a response, and parse that response for the information you need.
Edit 2: Having noted the above, and having done various testing, I’ve struggled in the terminal after calling the File Chooser via gdbus, to listen for a response via the object path it returns, but it doesn’t return via that and I’ve only really been able to see some output from the file selection via dbus-monitor, which is fiddly to parse. It’s probably more viable to write a script, e.g. with python and using dbus-python to call the File Chooser. So, again, generally just easier to use something like kdialog (or zenity for a non-Qt option).
The following documentation may still provide some help for people coming here at a future point: