Raspberry Pi sets up the python GUI program to start up, and customizes the startup screen

First, set up the python GUI program to start up
This method allows your program to start before the Raspberry Pi is on the desktop.
①Create a new .sh file and give it a name, such as start.sh. If your python file is in desktop app folder.
Then the content of start.sh is as follows:
cd /home/pi/Desktop/app
sudo python3 program.py

Enter the program path first and execute it in python. The advantage is that if the python program needs to call a file with a relative path, such as the db database in the directory, no error will be reported.

②Set the running permission to start.sh.
chmod +x start.sh
After setting, double-click start.sh to see if the program can run. If it can run normally, go to the next step, otherwise check whether the program path you set is correct.

③ Modify the rc.local file
sudo nano /etc/rc.local
On the line above the last line exit 0 add:
export DISPLAY=:0
X -nocursor -s 0 -dpms &
/home/pi/start.sh &
ctrl+x, then press y to save, press Enter to exit.
Note that the & at the end of the code must be added to let the program run in the newly opened process. Otherwise the Raspberry Pi will get stuck in your program. If the program can't exit, it's a tragedy. You can only modify the Raspberry Pi settings remotely through ssh.
At this point, the program can be started.
If that doesn't work, open the configuration file:
sudo nano ~/.config/lxsession/LXDE-pi/autostart
Add the absolute path of the start.sh file in the last line, such as:
@/home/pi/start.sh
Try restarting again.

2. Customize the startup screen of the Raspberry Pi
①Disable the boot rainbow screen and boot code scanning:
sudo nano /boot/config.txt
Find #disable_overscan=1, remove the preceding #.
Add disable_splash=1 to the last line of config.txt
ctrl+x save and exit.
②Disable the Raspberry Pi logo in the upper left corner and the code flow of the startup program:
sudo nano /boot/cmdline.txt

The first console=tty1, changed to console=tty3, and added logo.nologo loglevel=3 after the first line
ctrl+x save and exit.
③ Modify the startup screen
sudo raspi-config

Open the Raspberry Pi settings, select the third boot options, select splash screen, yes open.
This reboot will see the startup image that comes with the Raspberry Pi.
The path is /usr/share/plymouth/themes/pix/splash.png
Name the picture you want to replace as splash.png, put it in this path and replace it with the picture that comes with the system.
Restart it and see the effect.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324692192&siteId=291194637