Discussion:
Question on desktop file exec lines
Jerome Leclanche
2013-12-23 09:38:02 UTC
Permalink
See: http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s06.html

I think I already know the answer to both but I'd like to double-check.

1) When dealing with desktop files that have %u or %U in the name, if
the argument is a relative file path, the file path should be made
absolute with getcwd(), correct?

2) When dealing with %f or %F, the file path should *not* be expanded, correct?

Cheers

J. Leclanche
David Faure
2013-12-31 10:23:36 UTC
Permalink
Post by Jerome Leclanche
See: http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s06.html
I think I already know the answer to both but I'd like to double-check.
1) When dealing with desktop files that have %u or %U in the name, if
the argument is a relative file path, the file path should be made
absolute with getcwd(), correct?
Yes, this is the best approach, since the app might start in a different
working directory and therefore not find the file.

Note that the working directory can be specified in the .desktop file, or can
be up to the application's startup code - or the way it's started
(cf. kdeinit and other fork-and-exec launchers).
Post by Jerome Leclanche
2) When dealing with %f or %F, the file path should *not* be expanded, correct?
You mean in case it's relative? The same reasoning applies IMHO.

My code (i.e. KDE) never sends relative paths to the program started via a
desktop file.
--
David Faure, ***@kde.org, http://www.davidfaure.fr
Working on KDE, in particular KDE Frameworks 5
Jerome Leclanche
2014-01-27 16:55:05 UTC
Permalink
Post by David Faure
Post by Jerome Leclanche
See: http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s06.html
I think I already know the answer to both but I'd like to double-check.
1) When dealing with desktop files that have %u or %U in the name, if
the argument is a relative file path, the file path should be made
absolute with getcwd(), correct?
Yes, this is the best approach, since the app might start in a different
working directory and therefore not find the file.
Note that the working directory can be specified in the .desktop file, or can
be up to the application's startup code - or the way it's started
(cf. kdeinit and other fork-and-exec launchers).
Post by Jerome Leclanche
2) When dealing with %f or %F, the file path should *not* be expanded, correct?
You mean in case it's relative? The same reasoning applies IMHO.
My code (i.e. KDE) never sends relative paths to the program started via a
desktop file.
I thought about this a little longer and I changed my code to match yours.
This needs to be clarified in the spec. Anyone up for a patch?

J. Leclanche
Post by David Faure
--
Working on KDE, in particular KDE Frameworks 5
Loading...