By having a #!
line then the .desktop
file can be made executable and run directly (e.g. from a command line, or some file browsers).
The idea behind wrapping with env
is to handle different OS's where xdg-open
might be in different directories. For example, on Debian the program is in /usr/bin/xdg-open
but on another OS it might be elsewhere. The location of env
is pretty much fixed and this construct will effectively result in $PATH
being searched for the xdg-open
program.
On my Debian install no file in /usr/share/applications
is marked executable and none of them have a #!
line.
So if you want your .desktop
file to be executable then you need a #!
and wrapping it with env
will help in portability. If you don't need it to be executable then you don't need it.
.desktop
file in ~/.local/share/applications "as trusted" (e.g here's how gnome implemented this ..). So this is not a matter of "If you don't need it to be executable then you don't need it." – don_crissti Jul 10 '16 at 15:48