0

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

@xscreensaver

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

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

Inside this folder:

 ~/.config/autostart

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

[Desktop Entry]
Type=Application
Exec=/usr/bin/YOUR_APPLICATION/your_app.sh
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=YOUR_APPLICATION
Comment=

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 Dec 2 '16 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. – Shady Programmer Dec 3 '16 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 Dec 5 '16 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 – Shady Programmer Dec 5 '16 at 10:46
  • Sorted thanks was missunderstood how it worked but i see now – shaggs Dec 5 '16 at 11:20

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.