d3cka2d3pwood
Posts: 5
Joined: Wed Dec 13, 2017 7:18 am

Raspbian Jessie, Autostart Python Script after GUI

Wed Dec 13, 2017 10:36 am

I'm trying to autostart a python script, pygame file once Rasbian boots up. I have tried changing the autostart file in
/home/pi/.config/lxsession/LXDE-pi
to:

Code: Select all

@lxpanel --profile LXDE-pi  
@pcmanfm --desktop --profile LXDE-pi  
@python /home/pi/faller/main.py  
@xscreensaver -no-splash  
@point-rpi
from

Code: Select all

@lxpanel --profile LXDE-pi  
@pcmanfm --desktop --profile LXDE-pi  
@xscreensaver -no-splash  
@point-rpi
But nothing happens. Although when I have tried autostarting lxterminal in this way it works using

Code: Select all

@lxpanel --profile LXDE-pi  
@pcmanfm --desktop --profile LXDE-pi  
@lxterminal   
@xscreensaver -no-splash  
@point-rpi  
I'm using 2017-04-10-raspbian-jessie as this is the latest version that the TFT screen i'm using works with.

Any help would be appreciated

klricks
Posts: 4959
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Raspbian Jessie, Autostart Python Script after GUI

Wed Dec 13, 2017 12:59 pm

Your entry should be like this:

Code: Select all

@lxterminal -e python /home/pi/faller/main.py 
Note that when/if your program terminates then the LXterminal will then immediately terminate as well.
Go here for my RPi writeup. Basic config, Serial Port add-on etc:
http://blackeagle12.net/Comp/RPi/Rpi.html Click contact icon then world icon --->

d3cka2d3pwood
Posts: 5
Joined: Wed Dec 13, 2017 7:18 am

Re: Raspbian Jessie, Autostart Python Script after GUI

Wed Dec 13, 2017 2:06 pm

Thank you very much for you fast reply, I'll give this a go tonight.

d3cka2d3pwood
Posts: 5
Joined: Wed Dec 13, 2017 7:18 am

Re: Raspbian Jessie, Autostart Python Script after GUI

Wed Dec 13, 2017 6:04 pm

Hi again,
It works for a second then shuts down.

when I run manually i.e typing python main.py the program runs fine.

see video here:
https://drive.google.com/file/d/1P0JpR2 ... sp=sharing

52 secs in the videos the traceback error says there is a pygame error, i.e. its unable open an image. Why does this work fine when I run the program manually but not when I run it automatically?

The particular file is unrestricted/all permissions open.
Last edited by d3cka2d3pwood on Wed Dec 13, 2017 6:14 pm, edited 1 time in total.

klricks
Posts: 4959
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Raspbian Jessie, Autostart Python Script after GUI

Wed Dec 13, 2017 6:14 pm

d3cka2d3pwood wrote:
Wed Dec 13, 2017 6:04 pm
Hi again,
It works for a second then shuts down.

when I run manually i.e typing python main.py the program runs fine.

see video here:
https://drive.google.com/file/d/1P0JpR2 ... sp=sharing
Make sure the entry is typed exactly as shown above with spaces but with no extra spaces.
Note for testing it is much faster to log out then log back in rather than rebooting...
Go here for my RPi writeup. Basic config, Serial Port add-on etc:
http://blackeagle12.net/Comp/RPi/Rpi.html Click contact icon then world icon --->

d3cka2d3pwood
Posts: 5
Joined: Wed Dec 13, 2017 7:18 am

Re: Raspbian Jessie, Autostart Python Script after GUI

Wed Dec 13, 2017 6:24 pm

it is exactly the same?

:?

Code: Select all

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash
@point-rpi
@lxterminal -e python /home/pi/faller/main.py

d3cka2d3pwood
Posts: 5
Joined: Wed Dec 13, 2017 7:18 am

Re: Raspbian Jessie, Autostart Python Script after GUI

Wed Dec 13, 2017 6:30 pm

Its ok i've sussed it :)

I had to put the full file path for the image in my code

Thanks for your help klricks

Return to “Python”

Who is online

Users browsing this forum: elParaguayo and 23 guests