I tried and tested @terdon's .desktop file yesterday. Here it is:
"A cleaner way would be to write a .desktop file that launches your script and then double click that. Something like:
[Desktop Entry] Exec=/home/user/yourscript.sh Terminal=true Type=Application
Save that file as
foo.desktop
in your~/Desktop
folder. That will now appear as an icon there and double clicking it will cause your script to be run in a terminal. Obviously, you need to change/home/user/yourscript.sh
to the actual path of your script
When I follow @terdon's suggested steps, the double click behavior of my Ubuntu 16.04 Unity desktop files is intermittent. Sometimes it succeeds, other times it fails to launch the bash script pointed to in the Desktop Entry's exec line.
Why might this occur and how do I fix this problem?
Here is /home/venker/.local/share/applications/fsu.desktop
that fails
[Desktop Entry]
Exec=/home/venker/Debug/My_NVR_Recorder.exe.cfg
Terminal=true
Type=Application
Here is /home/venker/Debug/My_NVR_Recorder.exe.cfg
that works:
#!/bin/bash
/home/venker/Debug/Generic.cfg -start /home/venker/Debug/My_NVR_Recorder.exe "Recorder Manage"
Here is /home/venker/Debug/Generic.cfg
that works:
#!/bin/bash
if [ $1 == "-start" ]; then
exec /usr/lib/mono/4.5/mono-service.exe $2 & >& /dev/null
else
pkill "$3"
mystring="/tmp/${2}.lock"
rm "$mystring"
fi
The above 3 files are rwxr_xr_x protected.
Here is an example of a script file, /home/venker/Debug/My_NVR_Recorder.exe.cfg, that works:
#!/bin/bash
exec /usr/lib/mono/4.5/mono-service.exe /home/venker/Debug/My_NVR_Recorder.exe &