Read the statement by Michael Teeuw here.
Auto-start MagicMirror after reboot (Raspberry Pi)
-
My Raspberry Pi mirror has shut off a few times by accident (overheated, lost power, etc). Every time I turned it back on it was kind of a pain - I had to take the mirror off the wall, hook up my keyboard and mouse, start up the mirror, etc. This happened enough that I wanted to automate a solution. I finally found this article and followed “method 2”. I thought I’d summarize here in case this can help anyone else.
What this will do
Start up your mirror whenever your raspberry pi gets turned on.
How?
We’ll utilize Raspian’s
autostart
mechanism to run a shell script whenever your Raspberry Pi starts up. The shell script will turn off sleep mode on your Pi and start your mirror.1) Write a shell script
Create a shell script in the home directory. From the terminal, type:
$ vi /home/pi/start-mirror.sh
Copy this code into the
start-mirror.sh
file that was just opened, then save and close the file:#!/bin/bash sudo xset -dpms sudo xset s off cd /home/pi/MagicMirror && npm start
3) Create a .desktop file
This will utilize the
autostart
system on the pi. Your script will run after the desktop system starts up.$ mkdir /home/pi/.config/autostart $ vi /home/pi/.config/autostart/mirror.desktop
Note: you might not need to run the first command to create the autostart directory - I already had this directory on my computer.
Copy this code into the mirror.desktop file and save it:
[Desktop Entry] Type=Application Name=MirrorStart Exec=sh /home/pi/start-mirror.sh
After this saves, you’re all set. Reboot the pi and test it out:
sudo reboot
After the reboot you should see the Desktop pop up for 10-20 seconds, then your mirror should automatically start up.
-
@pbelanger but u can do it a lot easier with node process manager (aka pm2)…
it will start on boot, restart if failed, etc,etc,etc
if U used my install scripts, it was an option,
I also provide the setup script to add this on after installsee https://github.com/sdetweil/MagicMirror_scripts
last entry
fixuppm2.shone copy/paste
this works the same on Windows, Linux and Mac
no special files, no services, …
-
Yeah, I’d recommend the PM2 method. In my install, I’ve also got an 18650 battery based UPS in place along with proper cooling… the UPS automatically shuts down the Pi if on battery too long, and will restart it for me. Easy as Pi(e).