1

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 &
9
  • Can you give us an example of a script that fails and one that works? Are you sure it fails? How does it fail? Please edit your question and give us more details.
    – terdon
    Commented Jun 1, 2016 at 10:05
  • @terdon, Thank you for your comment. I have provided an example of the fsu desktop file(s) that fails. I am sure it fails by not creating a mono-service process and a lockfile in the /tmp directory.
    – Frank
    Commented Jun 1, 2016 at 10:57
  • @terdon, Thank you for your comment. I have added my script file contents which work at the end of my original question.
    – Frank
    Commented Jun 1, 2016 at 11:03
  • I ran desktop-file-validate /home/venker/.local/share/applications/fsu.desktop this morning and it complained about fsu.desktop file missing a Name entry. I corrected that error and fsu.desktop still does not launch the process specified by the Exec entry in fsu.desktop. This is very puzzling.
    – Frank
    Commented Jun 1, 2016 at 16:11
  • I don't understand. Which of these scripts fail when launched from the .desktop file? You say that they all work.
    – terdon
    Commented Jun 1, 2016 at 16:35

1 Answer 1

1

Here is how I eliminated the intermittent behavior of double clicking the fsu.desktop.

This is fsu.desktop.

[Desktop Entry]
Name=FSU79
Exec=/usr/bin/gnome-terminal  -e  "bash  -c   /home/wendy/Debug/My_HDR_Recorder.exe.cfg"
Terminal=false
Type=Application

This is /home/wendy/Debug/Generic.cfg

#!/bin/bash

if [ $1 == "-start" ]; then 
    cd /home/wendy/Debug
    exec /usr/lib/mono/4.5/mono-service.exe $2 & >& /dev/null 
else 
   pkill "$3"
   exe=$(echo $2 | grep -oE "[^/]+$")
   mystring="/tmp/${exe}.lock"
   rm "$mystring"
fi

This is /home/wendy/Debug/My_HDR_Recorder.exe.cfg

#!/bin/bash
nohup /home/wendy/Debug/Generic.cfg -start /home/wendy/Debug/My_HDR_Recorder.exe "Recorder Manage"

[EDIT June 2 2016 9:35 pm Could someone let our architect or I know the reason why this totally eliminates the intermittent behavior of double clicking the fsu.desktop? Thank you in advance.]

3
  • What is the reason this answer totally eliminates the intermittent behavior of double clicking the fsu.desktop? Thank you
    – Frank
    Commented Jun 2, 2016 at 13:11
  • I discovered this morning another cause for intermittent double click behavior. When we move the binary nohup from My_HDR_Recorder.exe.cfg to Generic.cfg, it causes intermittent double click behavior 50 percent or greater of all test cases. May I ask what this phenomena occurs?
    – Frank
    Commented Jun 2, 2016 at 14:13
  • @n.st, When we move the binary nohup from My_HDR_Recorder.exe.cfg to Generic.cfg, it causes intermittent double click behavior 50 percent or greater of all test cases. May I ask what this phenomena occurs? Thank you.
    – Frank
    Commented Jun 2, 2016 at 17:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .