How can I make my python scripts load and run one time once the desktop loads?

I've put the python scripts into .sh files

Ive edited autostart and called them using

@lxterminal -e "./start.sh"
@lxterminal -e "./start2.sh"

And yes added them before


right now both scrpits loop although they shouldn't.

If I remove the @ or do --command not -e I have same issue of the scripts looping

Here is my start.sh

cd /home/pi
sudo python led.py #makes led flash 5sec on 5 sec off twice then end

1 Answer 1


Inside this folder:


Add a file with .desktop extension. Below is the basic structure for yourapp_autostart.desktop file:

[Desktop Entry]

Ofcourse adjust the names of the file and scripts to your liking.

  • Thanks... Is it best to make a folder in /usr/bin or best to call from /home/pi?
    – shaggs
    Commented Dec 2, 2016 at 18:44
  • You should be able to run your files from /home/pi no problem. However in terms of best practice I don't know myself. Commented Dec 3, 2016 at 11:21
  • Is there a way to make it start once the dektop starts. My python script has a gui elemnet and is not shown wih way above?
    – shaggs
    Commented Dec 5, 2016 at 10:24
  • THIS is the way to make it start once the desktop starts. If you're having trouble with it you might want to have a look at changing some settings in that file Commented Dec 5, 2016 at 10:46
  • Sorted thanks was missunderstood how it worked but i see now
    – shaggs
    Commented Dec 5, 2016 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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