I have searched a great deal and have been unable to find an answer to this. What does the TryExec
field do in .desktop files? How does it differ from the Exec
field?
Asked
Active
Viewed 1.8k times
33

Mike Pierce
- 757

Rohan
- 3,561
-
2Path to an executable file on disk used to determine if the program is actually installed. If the path is not an absolute path, the file is looked up in the $PATH environment variable. If the file is not present or if it is not executable, the entry may be ignored (not be used in menus, for example). – don_crissti Feb 17 '16 at 20:04
-
@don_cissti: you should add this as an answer. For completeness add the link to https://developer.gnome.org/desktop-entry-spec/. – Bram Aug 15 '16 at 21:03
1 Answers
30
According to standards.freedesktop.org, the TryExec
entry takes the following:
Path to an executable file on disk used to determine if the program is actually installed. If the path is not an absolute path, the file is looked up in the $PATH environment variable. If the file is not present or if it is not executable, the entry may be ignored (not be used in menus, for example).
Desktop Application Autostart Specification states:
A .desktop file with a non-empty TryExec field MUST NOT be autostarted if the value of the TryExec key does NOT match with an installed executable program.
Unlike Exec
and despite the similar name, TryExec
does not actually execute it's value.

Mike Pierce
- 757
-
And what
$PATH
is used? It seems that changes to the$PATH
made by the user's shell config are not included. – ntc2 Dec 22 '18 at 04:21 -
1I ran into an issue. I hope this saves someone else time. I don't think the TryExec path can be a symlink. I wasn't seeing my .desktop file show up in the list of sessions for my greeter and as soon as I changed my TryExec from a symlink to a direct copy of the file, it worked. – Eric Ihli May 18 '21 at 04:44
-
@ntc2 the
$PATH
that is passed to the application launcher's environment. If you changed the PATH of your shell, it might affect the launcher's environment if you did it early enough, (e.g. in .bash_login in the case of bash), or similar for other shells. If you're doing it in .bashrc, probably not? You'll have to look up the config loading specifics of your shell. – Victor Sep 25 '23 at 13:18