I am new to Linux, and I am using Ubuntu 16.04.

I am trying to create a .desktop file for the simplest code ever. However, I can't figure out why, but when I double-click it, nothing happens besides the fact that the icon shows up in the Launcher for a few seconds.

Here's my .desktop file :

[Desktop Entry]
Comment=No comment for now

Here's the Test.sh file it runs :

python Test.py

Here's the target Test.py file :

f = open("Test.txt", "w") 
f.write("Test successful!")

The .desktop, .sh and .py files are all in /home/julien/Desktop and have permissions chmod +x. When I run Test.sh from the terminal, everything works fine and the Test.txt file is created. However, when I double-click on my Shortcut-Test icon, nothing seems to happen.

Does anyone manage to make this simple example work? Any help is welcome!

  • 3
    If this was working from a terminal then you must have been at the Desktop prompt. To use via the .desktop launcher then Test.sh must use full path to Test.py, i.e. python /home/julien/Desktop/Test.py – doug Feb 26 '17 at 23:49

To run the python script you have to put the full path or ./Desktop/Test.py in the sh file because when you run the Test.sh file the path where the script will run in /home/julien, so it is just a problem of bad files locations of the files or misleadings paths. It helps to "debug" to set the Terminal=true and adding some waiting time to the Test.sh file (e.g. sleep 20 in the end of the file) to see the output of the script

| improve this answer | |
  • 1
    Thanks for bot the help and the debugging tip.. works fine now! – Julep Feb 26 '17 at 23:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.