Here is a quick way to have an application built on electron run at boot on a Raspberry Pi. This worked for me running Raspian Stretch with Desktop.
Edit /home/pi/.config/lxsession/LXDE-pi/autostart
with nano:
1 |
sudo nano /home/pi/.config/lxsession/LXDE-pi/autostart |
Add the following line:
1 |
@npm start --prefix /path/to/project/ |
The file should now look somewhat like this:
1 2 3 4 5 |
@lxpanel --profile LXDE-pi @pcmanfm --desktop --profile LXDE-pi @xscreensaver -no-splash @point-rpi @npm start --prefix /path/to/project/ |
Save and exit nano and reboot. Your app should open after the desktop environment loads. Yay!
If you want to be able to get access to the terminal output of your application, install screen with:
1 |
sudo apt-get install screen |
And then swap:
1 |
@npm start --prefix /path/to/project/ |
For:
1 |
@screen -d -m npm start --prefix /path/to/project/ |
In the above code snippets.
After the pi boots, you can run screen -list
to see what screens are available to attach to then attach to yours with screen -r yourscreen
. Here’s an example:
Press enter, and then see your terminal output.
For more info on how to use screen, check out this link:
https://www.gnu.org/software/screen/manual/screen.html
1 Comment