0

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:

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

from

@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

@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

0

You can apply this technique.

Create a service:

$ sudo vi /lib/systemd/system/myautostartscript.service

Copy the following code and paste it (for Python 2.7; replace python2.7 with python3 for Python 3) and edit WorkingDirectory (your_python_file.py file directory) :

[Unit]
Description=My service
After=network.target

[Service]
ExecStart=/usr/bin/python2.7 -u your_python_file.py
WorkingDirectory=/home/pi/myscript
StandardOutput=inherit
StandardError=inherit
Restart=always
User=pi

[Install]
WantedBy=multi-user.target

Give execution permission to your_python_file.py file:

$ sudo chmod +x your_python_file.py

Give auto Start Enable command:

$ sudo systemctl daemon-reload
$ sudo systemctl enable myautostartscript.service
| improve this answer | |

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.