RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    Modify a safe shutdown script.

    Scheduled Pinned Locked Moved Help and Support
    shutdown scriptshutdownmenu
    20 Posts 5 Posters 5.6k Views
    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.
    • SixSpeedDeathS
      SixSpeedDeath @cyperghost
      last edited by

      @cyperghost @mediamogul, I REALLY want to thank you for all your help.

      I'm trying to change careers to Linux admin, and the RetroPie has been my "Carrot" for learning the OS.

      Gradually, I'm picking the stuff up, but responses with information like what is supplied here do more than help me get a toy working, it's something I plan to use for the rest of my life.

      I can only Bury my nose in a CompTIA book for so long before I need some hands on, and this is exactly what I needed.

      Thank you.

      mediamogulM 1 Reply Last reply Reply Quote 1
      • mediamogulM
        mediamogul Global Moderator @SixSpeedDeath
        last edited by

        @sixspeeddeath

        Glad it worked out for you.

        RetroPie v4.5 • RPi3 Model B • 5.1V 2.5A PSU • 16GB SanDisk microSD • 512GB External Drive

        Drakaen391D 1 Reply Last reply Reply Quote 1
        • Drakaen391D
          Drakaen391
          last edited by

          So, I love Python over Bash...

          but I cant convert one over the other....

          Any Ideas how to convert this to python?

          RPi B & RPi 3B OC (Now Raspberry pi 4b 8gb)
          Retropie (Latest Stable)
          PiBox with Wind Tunnel Cooling System

          1 Reply Last reply Reply Quote 0
          • Drakaen391D
            Drakaen391 @mediamogul
            last edited by

            @mediamogul I am using the original safe shutdown part...

            import RPi.GPIO as GPIO
            import os
            import time
            
            
            ###look at the GPIO for the Button Switch to be depressed
            
            GPIO.setmode(GPIO.BCM)
            GPIO.setup(3, GPIO.IN, pull_up_down=GPIO.PUD_UP)
            GPIO.wait_for_edge(3, GPIO.FALLING)
            
            def main():
                while True:
                    es-close()
            
            def es-close():
                os.system("/etc/killes.sh")
            
            while True:
                print((es-close))
                time.sleep(1)
                os.system("shutdown now")
            

            and a very slightly modded es shutdown code

            #!/bin/bash
            
            ##############################
            #This Script was created by  #
            #meleu on the retropieforums.#
            ##############################
            
            
            # Check if EmulationStation is running. Finish the script if doesn't.
            espid="$(pgrep -f "/opt/retropie/supplementary/.*/emulationstation([^.]|$)")" || exit 0
            
            # the "sed" command below isn't a crypted message :), it's just a trick to
            # make $emucall regex-safe to use in the "pgrep -f" below.
            emucall="$(sed '4!d; s/\([\\"]\|[[:alnum:]_]\+=[^ ]* \)//g; s/[][(){}^$*.|+? ]/\\&/g' /dev/shm/runcommand.info)"
            
            # If there's an emulator running, we need to kill it and go back to ES
            if [[ -n "$emucall" ]]; then
                emupid="$(pgrep -f "$emucall" | tr '\n' ' ')"
                pkill -P "$(echo $emupid | tr ' ' ',')"
                kill "$emupid"
                wait "$emupid"
                sleep 0.5
            fi
            
            kill "$espid"
            wait "$espid"
            sleep 0.5
            

            RPi B & RPi 3B OC (Now Raspberry pi 4b 8gb)
            Retropie (Latest Stable)
            PiBox with Wind Tunnel Cooling System

            cyperghostC 1 Reply Last reply Reply Quote 0
            • QuackwalksQ
              Quackwalks
              last edited by

              I'm not understanding how or where to fix the problem of the kintaro 9000 case not saving metadata.

              Pi Model or other hardware: Pi 3b
              Power Supply used: 5.1v 2.5a
              RetroPie Version Used: 4.3.17
              Built From: Pre made SD Image on RetroPie website, updated to 4.3.17
              USB Devices connected: dongle for wireless keyboard
              Controller used: Official PS3 Controller

              Drakaen391D 1 Reply Last reply Reply Quote 0
              • Drakaen391D
                Drakaen391 @Quackwalks
                last edited by

                @quackwalks Do you by chance have a large number of roms scraped?

                RPi B & RPi 3B OC (Now Raspberry pi 4b 8gb)
                Retropie (Latest Stable)
                PiBox with Wind Tunnel Cooling System

                QuackwalksQ 1 Reply Last reply Reply Quote 0
                • QuackwalksQ
                  Quackwalks @Drakaen391
                  last edited by

                  @drakaen391 I do have a large number of roms scraped.

                  Drakaen391D 1 Reply Last reply Reply Quote 0
                  • Drakaen391D
                    Drakaen391 @Quackwalks
                    last edited by

                    @quackwalks that could be the issue, increase the wait time a few seconds because emulationstation takes more time to save the meta data if there are alot of scrapped roms

                    RPi B & RPi 3B OC (Now Raspberry pi 4b 8gb)
                    Retropie (Latest Stable)
                    PiBox with Wind Tunnel Cooling System

                    mediamogulM 1 Reply Last reply Reply Quote 0
                    • mediamogulM
                      mediamogul Global Moderator @Drakaen391
                      last edited by

                      @drakaen391 said in Modify a safe shutdown script.:

                      increase the wait time a few seconds

                      A static wait time really isn't a good idea for something like this. If you use something similar to the while statement in my example above, it will always take as as much time as it needs, no matter what the circumstances.

                      RetroPie v4.5 • RPi3 Model B • 5.1V 2.5A PSU • 16GB SanDisk microSD • 512GB External Drive

                      1 Reply Last reply Reply Quote 1
                      • cyperghostC
                        cyperghost @Drakaen391
                        last edited by

                        @drakaen391 About your posted codings.... Does the wait command works in your case? @mediamogul and his while-loop by monitoring PID status is imho better ...

                        wait can only be used on child processes out of the own subshell

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post

                        Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

                        Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.