• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Auto-start MagicMirror after reboot (Raspberry Pi)

Scheduled Pinned Locked Moved General Discussion
3 Posts 3 Posters 6.5k Views 3 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    pbelanger
    last edited by pbelanger Sep 12, 2021, 9:24 PM Sep 12, 2021, 9:23 PM

    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.

    S 1 Reply Last reply Sep 12, 2021, 10:07 PM Reply Quote 1
    • S Offline
      sdetweil @pbelanger
      last edited by Sep 12, 2021, 10:07 PM

      @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 install

      see https://github.com/sdetweil/MagicMirror_scripts

      last entry
      fixuppm2.sh

      one copy/paste

      this works the same on Windows, Linux and Mac

      no special files, no services, …

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      B 1 Reply Last reply Sep 14, 2021, 6:08 AM Reply Quote 1
      • B Offline
        BKeyport Module Developer @sdetweil
        last edited by Sep 14, 2021, 6:08 AM

        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).

        The "E" in "Javascript" stands for "Easy"

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        1 / 1
        • First post
          3/3
          Last post
        Enjoying MagicMirror? Please consider a donation!
        MagicMirror created by Michael Teeuw.
        Forum managed by Sam, technical setup by Karsten.
        This forum is using NodeBB as its core | Contributors
        Contact | Privacy Policy