Autorun Python script at desktop start

BASH OK + AutoStart:

sudo nano ~/.config/lxsession/LXDE-pi/autostart

@lxpanel –profile LXDE-pi
@pcmanfm –desktop –profile LXDE-pi
#@xscreensaver -no-splash
@xset s off
@xset -dpms
@xset s noblank
@lxterminal –command « /home/pi/startup.shl »

sudo nano startup.shl

#!/bin/bash
ls
aplay Star-Wars-R2D2.wav
sleep 3
source ~/.profile
workon cv
python testvideofacedetect33.py

sudo chmod +x startup.shl

./startup.shl

sudo reboot

 

Autre méthode

https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=136875&p=924039

by JimmyN » Wed Mar 09, 2016 4:40 am
If you just want to autostart a Python file you don’t need to create a .desktop file. Do that if you want to create a desktop shortcut or add it to the menu. You can run the file directly by adding it to your autostart.

nano ~/.config/lxsession/LXDE-pi/autostart

Scroll down and add this line at the bottom.

Désactiver l’économiseur d’ecran :

#@xscreensaver nosplash
@xset s off
@xset dpms
@xset s noblank
@lxterminal

@sudo /usr/bin/python /path/to/your/script.py

Save and exit. The file will run when the desktop starts.

sudo nano ~/.bashrc 
@lxterminal -e aplay Star-Wars-R2D2.wav
@lxterminal -e source ~/.profile
@lxterminal -e workon cv
@lxterminal -e python testvideofacedetect33.py
 

ou

 

https://www.raspberrypi.org/forums/viewtopic.php?f=32&t=135571&p=905081#p905081

 

 

Soyez le premier à commenter

Poster un Commentaire

Votre adresse de messagerie ne sera pas publiée.


*