Updated 21-4-2020 to correct typo.
To automatically run a python program when the PIXEL loads, you need to add a command to the autostart file that can be found here:
/etc/xdg/lxsession/LXDE-pi/autostart
Here’s the process:
- Open the autostart file: sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
- Create a new line above the line beginning: @xscreensaver
- On the new line add the command to start your program or script. NB: You should include the full path name
- Save and exit with ctl x then y then Enter.
- Next time the Pi boots, your program will run.
Mike – G4WNC
This worked like a charm. Thanks!
Hi Jay,
Thanks for the feedback 🙂
I am not sure if this is just outdated.. or a typo… but I did spend about 4 hours working on this issue. There are about 10,000 posts and methods to this. This was the one that worked.. so wanted to be sure to point out in case something gave up on it too early:
Shouldnt this be:
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
?
Hi Aaron,
You’re correct, that is a typo. Thanks for spotting and reporting it. I’ve just updated the post so it should now be correct.
Thanks,
Mike