Relative paths in .desktop, .service files' Exec= lines

Jasper St. Pierre jstpierre at
Thu Jun 23 18:28:12 UTC 2016

Uh, so this might be a dumb question, but how do relative paths help

Doesn't resolving paths relative to the .desktop file mean that it is
intricately linked to the filesystem layout?

This would break something like Alacarte, which, when you might want
to put an icon in another folder, copies it into
~/.local/share/applications. If the Exec= line had "../bin/my-app",
then it would break.

This doesn't seem to help flatpak, which would have the .desktop file
hardlinked into the user's system at /usr/share/applications, but the
binscript would be inside the container at /app/bin...

The only thing I can think this case helping is where the .desktop
file and binscript are together in the same directory, for, e.g. /opt/
installations. If we want to improve those, sure, but I think we
should perhaps limit it to CWD-only, "./my-bin" rather than allowing
full relative paths...

On Thu, Jun 23, 2016 at 11:10 AM, Michal Suchanek <hramrach at> wrote:
> On 23 June 2016 at 19:54, Simon McVittie <simon.mcvittie at> wrote:
>> On 23/06/16 17:53, Allison Lortie wrote:
>>> On Mon, Jun 20, 2016, at 13:24, Simon McVittie wrote:
>>> On the other hand, what we are doing here very much might break the
>>> previously working behaviour of making symlinks from
>>> /usr/share/applications into the user's home directory.
>> Right, that's a valid concern.
>>> On the other other hand, if we follow this all the way down the rabbit
>>> hole, we may get into weird situations whereby we're canonicalising
>>> symlinks in situations where /usr is a symlink to /mnt/usr or something
>>> equally awful, in which case we might end up at the wrong result.
>> Indeed. I specifically don't want to do that.
>>> For
>>> that reason, I think we should limit any resolution step here to direct
>>> inspection of the desktop file in question for being a symlink, itself,
>>> and not attempt a full canonicalisation.
>> OK. So are you thinking of something like this pseudocode?
>>     path = $HOME/Desktop/dconf-editor.desktop   # or something
>>     data = load(path)
>>     working_directory = data["Path"]
>>     argv = split(data["Exec"])
>>     if argv[0] is absolute:
>>         chdir(working_directory)
>>         execv(argv[0], argv)
>>     else if argv[0] contains a path separator:
>>         if lstat(path) says it's a symlink:
>>             link_target = readlink(path)
>>             # assume join() is syntax-only manipulation like
>>             # Python os.path.join, and does not look at the disk
>>             reference = join(dirname(path), link_target)
> This is a bit fishy. Link target may be absolute or relative path.
> You can (ab)use this to your advantage, too.
> Typically the desktop symlink will be absolute to / and desktop file
> linking as part of installation will be typically relative.
> Thanks
> Michal
> _______________________________________________
> xdg mailing list
> xdg at


More information about the xdg mailing list