Raspberry Pi automatically runs the program

Source: Internet
Author: User

Http://blog.csdn.net/c80486/article/details/8460325

If Raspberry Pi is made into an electric appliance, several actions must be supported when it is powered on.

1. Automatic Logon

2. automatically run the startx startup Window System

3. After the window system is started, it automatically runs the custom program (generally the main interface of the application)

I have studied this.

Automatic Login: Modify the/etc/inittab File

Sudo nano/etc/inittab

Scroll down and find Row 1: 2345: respawn:/sbin/Getty 115200 tty1
Comment out this line and modify it to #1: 2345: respawn:/sbin/Getty 115200 tty1
Add a line of content 1: 2345: respawn:/bin/login-f pi tty1 </dev/tty1>/dev/tty1 2> & 1

Press Ctrl + X to exit. Remember to press y to save

Principle: When Linux is started, it reads the inittab file, runs the logon command, and automatically logs on with the PI user name.

Automatically run the startx startup Window System: Modify the/etc/rc. Local file

Sudo nano/etc/rc. Local

Add a line of Su Pi-C startx at the end of the file (before exit 0)

This command is used to execute startx as a PI user.

Press Ctrl + X to exit. Remember to press y to save

Restart

Sudo reboot

After this start, you will directly log on to the system as a PI user and start startx immediately.

Principle: When Linux is started, the user will execute the/etc/rc. Local script file after logging on. Generally, we put the command to be automatically executed in this file.


How to automatically run custom programs after the window system is started


Enter the. config directory under the current user's home directory (this is a hidden directory, which must be displayed by LS-)

Cd ~ /. Config

The current user is pi, and the home directory is/home/PI. The above command is equivalent to CD/home/PI/. config

Create a subdirectory named autostart and enter the Directory

Mkdir autostart

CD autostart

Generate a *. desktop file (for example, my. desktop). The command is as follows:

Sudo nano my. Desktop

Enter the following file content:


[Desktop entry]
Type = Application
Exec = Midori

The value of the last exec statement is the name of the program to be started (preferably the full-path executable file name). Here is the Midori browser.

Press Ctrl + X to exit. Remember to press y to save the disk.


OK. Just restart startx.

Principle: After startx, lxde window manager will find ~ All. Desktop files under the/. config/autostart directory are executed one by one.

Link all the above to power-on: Automatic Logon-Automatic startup window-automatic program running

Net reference: http://www.elinux.org/RPi_Debian_Auto_Login

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.