I created a simple desktop file to check the connectivity of remote location in which Exec=ping 192.168.0.9
. But one file created with #!/usr/bin/env xdg-open
before Desktop Entry and another without #!/usr/bin/env xdg-open
and both worked the same. Then What is the use of it in desktop file? What does it mean?
1 Answer
As per this answer , the use of #!/usr/bin/env xdg-open
was meant to serve as a way to launch applications that referenced in .desktop
file via command line. But as of now, it doesn't work and only opens .desktop
file as text file in gedit
. Nowadays , if you want to launch a .desktop
app via command line, you must do some pre-processing of the file itself.
As for use of #!
it basically tells your computer which interpreter to use with this file. In this case, /usr/bin/env
which will return path to xdg-open
command (i.e, this calls xdg-open
to read and execute your file ) .
-
Ok. Got it but you said "to launch a
.desktop
app via command line, you must do some pre-processing of the file itself. and what is that pre-process? Could you tell me? Aug 8, 2016 at 11:31 -
Preprocessing is just extracting the
Exec=
line. And there's plenty of tools for that: grep, awk,sed,python,perl. Just whatever works for you. Aug 8, 2016 at 16:44