Sometimes, we need to start a program when pi boot up, there are several ways to achieve it, I introduce two ways to configure it.
First way:Create a .desktop file
1.Create autostart folder
If you do not have the Espeak package installed, run the following in terminal to install: sudo apt-get install espeak. To learn more about how to get the Raspberry Pi speak, we have a tutorial here. In the /home/pi directory, open a file for editing: sudo nano sample.py. And enter the following code and save it (press CTRL+X and enter Y ). Raspbian is an operating system by the Raspberry Pi Foundation, the creators of the Raspberry Pi. It is the most used operating system on the Pi. This tutorial will show how to install Raspbian on your Raspberry Pi.
2.Write desktop file
A new window will open, type following command:
After typing, press “Ctrl + O” to save and press “Ctrl + X” to quit nano.
After reboot, the program will autostart when raspberry pi start up.
Note:
[Desktop Entry] is always in the first line.
Name: Specific name of the application.
Type: This specification defines 3 types of desktop entries: Application (type 1), Link (type 2) and Directory (type 3).
Exec: Program to execute, possibly with arguments.
lxterminal –e “home/pi/yourprogram” means you want to use LXTerminal open the program that stored in“home/pi/yourprogram”, yourprogram is an executable file.
If you don’t want to autostart the program:
Go to Root LXTerminal,
the desktop file will be deleted.
Second way:Create a script
1.Write a script to start the program
Create a new file in /home/pi/: autostart.sh
open it:
and write something:
2.configure to autostart the script
add the following lines before “eixt 0”
3.
Install Anydesk Debian 10
After reboot,the program will autostart when raspberry pi start up.
Install Anydesk Raspberry Pi
You can change the program file path, no need to put in /home/pi/.
^ . ^