g_app_info_create_from_commandline() always adds %u or %f to command
I'm not sure what's the reason that the g_app_info_create_from_commandline
always add %u or %f to the application launch command:
https://gitlab.gnome.org/GNOME/glib/-/blob/main/gio/gdesktopappinfo.c#L4354
Background:
Firefox use the executable path of chosen application for opening the downloaded files and also saves it for later reopening. While it generally works for the regular applications it fails for the flatpak ones because only /usr/bin/flatpak filename.ext
is started.
To fix that I would like to save the GAppInfo
of the selected application by storing application name and commandline. Later I would recreate the GAppInfo
data by g_app_info_create_from_commandline
and use the g_app_info_launch
which will correctly start for example the flatpak-ed application by translating host path into the document portal, etc.
But recreating the GappInfo by g_app_info_create_from_commandline always appends %u
or %f
even when it's already specified in the commandline and surrounded by the pair of @@, like:
/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=gimp-2.10 --file-forwarding org.gimp.GIMP @@u %U @@
become:
/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=gimp-2.10 --file-forwarding org.gimp.GIMP @@u %U @@ %f
This could break the execution by not creating the document portal and makes no sense.
Could we add a GAppInfoCreateFlags
flag to the g_app_info_create_from_commandline
which skips adding %u or %f to the commandline?