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.

    How to autorun script on MagicMirror boot

    Scheduled Pinned Locked Moved Solved Troubleshooting
    8 Posts 4 Posters 1.4k Views 4 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.
    • B Offline
      byte_me
      last edited by

      Hi all,

      I am having trouble getting my script for the PIR sensor to start on boot.

      I followed this guide which used to work until I did a fresh install with the latest version of MagicMirror.

      The guide suggests adding the following line to the autostart file in:

      ~/.config/lxsession/LXDE-pi
      
      @sudo /usr/bin/python /home/pi/MagicMirror/pir.py
      

      … however, I do not have the lxsession directory in ~/.config.
      I do have an autostart file in /etc/xdg/, but in the comments for the link I posted above it mentions that this is a global autostart file and the user one is preferred. The OP suggests manually creating the directory and autostart file using the path above, but that doesn’t seem to work either.

      A few things:

      • my test script shows both 0 and 1 values for the sensor, confirming that it is sensing motion properly.

      • Running my monitor_off.sh / monitor_on.sh scripts manually work as expected

      • Starting my pir.py script manually works as expected

      So, this leads me to believe that the problem is with the directory the autostart file is in.

      Any help on this is appreciated. Thanks!

      S 1 Reply Last reply Reply Quote 0
      • S Away
        sdetweil @byte_me
        last edited by

        @byte_me use pm2

        pm2 start xxx.py
        pm2 save

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        B 1 Reply Last reply Reply Quote 0
        • BKeyportB Offline
          BKeyport Module Developer
          last edited by

          I use PM2 and scripts to call the various external modules…

          EG: buttons.sh, mm.sh and omx.sh

          buttons.sh is a short script to launch python3 for buttons.py, my external button runner.
          mm.sh is the startup per the old instructions found in the old docks.
          omx.sh launches OMXplayer with a bunch of options.

          I wouldn’t use two of 'em, if I could get pm2 to launch with command line options.

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

          K 1 Reply Last reply Reply Quote 0
          • B Offline
            byte_me @sdetweil
            last edited by

            @sdetweil said in How to autorun script on MagicMirror boot:

            @byte_me use pm2

            pm2 start xxx.py
            pm2 save

            @BKeyport said in How to autorun script on MagicMirror boot:

            I use PM2 and scripts to call the various external modules…

            EG: buttons.sh, mm.sh and omx.sh

            buttons.sh is a short script to launch python3 for buttons.py, my external button runner.
            mm.sh is the startup per the old instructions found in the old docks.
            omx.sh launches OMXplayer with a bunch of options.

            I wouldn’t use two of 'em, if I could get pm2 to launch with command line options.

            Thank you both, this seems to have solved the issue!

            1 Reply Last reply Reply Quote 0
            • K Offline
              kelly97129 @BKeyport
              last edited by

              @BKeyport
              Hello
              Can you tell me or show me what your omx.sh and other scripts look like that you are running on pm2 because I am in raspi4 and buster updated and my MM is running hard and I don’t know why
              thank you in advance

              S BKeyportB 2 Replies Last reply Reply Quote 0
              • S Away
                sdetweil @kelly97129
                last edited by

                @kelly97129 if you run the

                 top 
                

                command, what process is most active?

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                K 1 Reply Last reply Reply Quote 0
                • K Offline
                  kelly97129 @sdetweil
                  last edited by kelly97129

                  @sdetweil
                  vncserver 3.6% ,squeezelite 13.9% and Xorg 4.5%

                  1 Reply Last reply Reply Quote 0
                  • BKeyportB Offline
                    BKeyport Module Developer @kelly97129
                    last edited by

                    @kelly97129 Sure. PM2 is simply the best way I’ve found to manage what’s running automatically on my system.

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

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    • First post
                      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