RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login

    Mausberry Shutdown Script Doesn't Save Metadata

    Scheduled Pinned Locked Moved ControlBlock, PowerBlock & Co.
    mausberry
    251 Posts 10 Posters 95.7k 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.
    • cyperghostC
      cyperghost
      last edited by cyperghost

      @NamErehWon Can you please check out. Detecting flanks on GPIO within bash would be fine. I know it works with wiringPi...
      So you can speed up GPIO change detection via IRQ - but I think that will be better discussed here

      1 Reply Last reply Reply Quote 0
      • hansolo77H
        hansolo77
        last edited by

        I wonder if you guys are just making it more complicated than it has to be. I also have a reset button wired up to the GPIO to act as a failsafe way to exit out a running game. The scripts are located here:
        https://www.reddit.com/r/raspberry_pi/comments/2yw4fn/finally_set_up_retropie_complete_with_a_gpio/cpdhtpu/
        So why not just incorporate that into the script? Just execute the escape script then initiate the shutdown? Of course if you wanted to make it beneficial for everybody, you'd probably want to add it into the Mausberry Script. The only problem I think is the type of scripts being used (shutdown is BASH why escape is PYTHON), so I don't think you can add it into the same script all at once..

        Who's Scruffy Looking?

        1 Reply Last reply Reply Quote 0
        • cyperghostC
          cyperghost
          last edited by cyperghost

          @hansolo77 No it isn't more complicated. You asked for a bash script. With C or python it is indeed an easy approch :) because string operations are much easier to do.

          You can see the results in different codestyle if you compare mine and @meleu.
          meleu use the tools (commands) every unix offers in an elegant way. I don't know so much commands so I'm poking around with stringscuts and string compare. That's exact the way you would do it in any coding language.

          BASH is immense powerful in working with files and data. As in every unix system hardware/devices are mounted into filesytem you can "communicate" to these devices via file manipulation :) So for fast results you can use BASH.

          Of course you can use the same bash-commands to work in python and do not need the shutdown script anymore. Or you can use commands like emupid=$(pgrep -f ${emucall:0:$pos}) to extract emulator calls. There are 1000 solutions.

          Our intention is to get an ultimate shutdown without using annother process in background to finsh ES and it's emulators (if they are running) as far as I see the python code it just kills obtained PID, like we do in version 1.5 of our bash script.


          EDIT:
          The python script will not work for zDoom for example. Because it just asks for "/opt/retropie/emulators/" path.

          @meleus intention works in this case as long as the call is initiated by runcommand.sh (and this is the normal usecase)

          meleuM 1 Reply Last reply Reply Quote 1
          • hansolo77H
            hansolo77
            last edited by

            And knowing is half the battle! -G.I.Joe!

            Who's Scruffy Looking?

            1 Reply Last reply Reply Quote 1
            • meleuM
              meleu @cyperghost
              last edited by

              @cyperghost said in Mausberry Shutdown Script Doesn't Save Metadata:

              With C or python it is indeed an easy approch :) because string operations are much easier to do.

              I doubt it! :-)

              • Useful topics
              • joystick-selection tool
              • rpie-art tool
              • achievements I made
              1 Reply Last reply Reply Quote 0
              • hansolo77H
                hansolo77
                last edited by

                Testing v1.5 from here now....

                • Exit from ES normally after playing a game
                  FAIL - Metadata did not save (although system did shut down)
                • Exit from running screensaver after playing a game
                  FAIL - Metadata did not save (although system did shut down)
                • Exit from playing a game (RetroArch)
                  FAIL - Metadata did not save (although RetroArch did close, return to ES, then shutdown.. Suggestion: shorten the wait time after returning to ES. I didn't know if it was working until it shut down lol)
                • Exit from playing a game (SuperMarioWar)
                  FAIL - Metadata did not save (although SuperMarioWar did close, return to ES, then shutdown. I also discovered that my Streets of Rage Remix game isn't working (crap) so I have to fix that soon)

                Take away - Looks like the script is properly closing out of the game I'm playing and returning to ES for a shutdown, but it's not saving the metadata when it shuts that down. I wonder if it's getting hung up in the if functions, not finding a valid true and going to the bottom of the script to the original poweroff without exiting ES first...

                So quick question... anybody know how to make a profile in Putty so it can automatically log in (username/password) so I don't have to keep typing it every time I try one of these tests? :)

                Who's Scruffy Looking?

                meleuM cyperghostC 2 Replies Last reply Reply Quote 1
                • meleuM
                  meleu @hansolo77
                  last edited by meleu

                  @hansolo77 said in Mausberry Shutdown Script Doesn't Save Metadata:

                  Exit from ES normally after playing a game
                  FAIL - Metadata did not save (although system did shut down)

                  Did you succeed saving metadata in this scenario with some other script?

                  I'm asking because several posts above I said that killing ES wouldn't save metadta and, If I understood well, @cyperghost said that you succeeded.

                  I think I misunderstood his answer.

                  anybody know how to make a profile in Putty so it can automatically log in

                  Maybe this can help.

                  • Useful topics
                  • joystick-selection tool
                  • rpie-art tool
                  • achievements I made
                  lostlessL 1 Reply Last reply Reply Quote 0
                  • lostlessL
                    lostless @meleu
                    last edited by lostless

                    @meleu I can confirm the 1.2 script works fine if you shut off from emulation station. But not from game

                    meleuM 1 Reply Last reply Reply Quote 0
                    • meleuM
                      meleu @lostless
                      last edited by meleu

                      @lostless said in Mausberry Shutdown Script Doesn't Save Metadata:

                      @meleu I can confirm the 1.2 script works fine if you shut off from emulation station.

                      Just to be really sure: "works fine" means "saves all new games I added to Favorites and/or Last Played", right?

                      • Useful topics
                      • joystick-selection tool
                      • rpie-art tool
                      • achievements I made
                      lostlessL 1 Reply Last reply Reply Quote 0
                      • lostlessL
                        lostless @meleu
                        last edited by

                        @meleu yes.

                        @meleu said in Mausberry Shutdown Script Doesn't Save Metadata:

                        Just to be really sure: "works fine" means "saves all new games I added to Favorites and/or Last Played", right?

                        meleuM 2 Replies Last reply Reply Quote 1
                        • meleuM
                          meleu @lostless
                          last edited by

                          @lostless please, give me a few minutes and I'll tweak the script v1.2 a little and post it to you try.

                          • Useful topics
                          • joystick-selection tool
                          • rpie-art tool
                          • achievements I made
                          1 Reply Last reply Reply Quote 1
                          • meleuM
                            meleu @lostless
                            last edited by meleu

                            @lostless please, install inotify-tools:

                            sudo apt-get install inotify-tools
                            

                            and then try the script below:

                            #!/bin/bash
                            # Before using this script you need to install inotify-tools:
                            #
                            #    sudo apt-get install inotify-tools
                            #
                            # I'm just trying to help with the script logic here.
                            # I DON'T HAVE A MAUSEBERRY AND DIDN'T TEST THE GPIO STUFF HERE!
                            #
                            #########################################################
                            #  U S E   I T   A T   Y O U R   O W N   R I S K ! ! !  #
                            #########################################################
                            #
                            # meleu - July/2017
                            # kudos for @cyperghost , who is very persistent in help you guys! :-)
                            
                            #this is the GPIO pin connected to the lead on switch labeled OUT
                            GPIOpin1=23
                            
                            #this is the GPIO pin connected to the lead on switch labeled IN
                            GPIOpin2=24
                            
                            echo "$GPIOpin1" > /sys/class/gpio/export
                            echo "in" > /sys/class/gpio/gpio$GPIOpin1/direction
                            echo "$GPIOpin2" > /sys/class/gpio/export
                            echo "out" > /sys/class/gpio/gpio$GPIOpin2/direction
                            echo "1" > /sys/class/gpio/gpio$GPIOpin2/value
                            
                            file="/sys/class/gpio/gpio$GPIOpin1/value"
                            
                            while inotifywait -qq -e modify "$file" ; do
                                power="$(cat "$file")"
                                [[ "$power" == 0 ]] && continue
                            
                                emu_command="$(sed -n 4p /dev/shm/runcommand.info)"
                                [[ -n "$emu_command" ]] && pkill -f "${emu_command%% *}" && sleep 5
                            
                                espid=$(pgrep -f "/opt/retropie/supplementary/.*/emulationstation([^.]|$)")
                                if [[ "$espid" ]]; then
                                    touch /tmp/es-shutdown && chown pi:pi /tmp/es-shutdown
                                    kill "$espid"
                                fi
                            
                                sudo poweroff
                            done
                            
                            • Useful topics
                            • joystick-selection tool
                            • rpie-art tool
                            • achievements I made
                            lostlessL 1 Reply Last reply Reply Quote 0
                            • lostlessL
                              lostless @meleu
                              last edited by

                              @meleu Im giving it a shot. I really don't want to reconfigure my pi, but oh what the heck. Ive only had to reconfigure 10 times or so. whats another for the most perfect script for mauseberry (or other switch) users.

                              meleuM 1 Reply Last reply Reply Quote 0
                              • meleuM
                                meleu @lostless
                                last edited by

                                @lostless I edited the script, be sure to get the current one!

                                • Useful topics
                                • joystick-selection tool
                                • rpie-art tool
                                • achievements I made
                                lostlessL 1 Reply Last reply Reply Quote 0
                                • lostlessL
                                  lostless @meleu
                                  last edited by

                                  @meleu i saw that. whew.

                                  lostlessL 1 Reply Last reply Reply Quote 1
                                  • lostlessL
                                    lostless @lostless
                                    last edited by lostless

                                    @meleu killed all switch functionality. As in it no longer functions as a shutdown switch.

                                    meleuM 2 Replies Last reply Reply Quote 0
                                    • meleuM
                                      meleu @lostless
                                      last edited by

                                      @lostless OK. I'll try a little further...

                                      • Useful topics
                                      • joystick-selection tool
                                      • rpie-art tool
                                      • achievements I made
                                      lostlessL 1 Reply Last reply Reply Quote 0
                                      • lostlessL
                                        lostless @meleu
                                        last edited by lostless

                                        @meleu i see you removed some stuff from the original script

                                        while [ 1 = 1 ]; do
                                        power=$(cat /sys/class/gpio/gpio$GPIOpin1/value)
                                        if [ $power = 0 ]; then
                                        sleep 1
                                        else
                                        

                                        that was removed. any reason to that?

                                        meleuM 1 Reply Last reply Reply Quote 0
                                        • meleuM
                                          meleu @lostless
                                          last edited by meleu

                                          @lostless said in Mausberry Shutdown Script Doesn't Save Metadata:

                                          that was removed. any reason to that?

                                          yep. This infinite loop is consuming CPU cycles unnecessarily.

                                          • Useful topics
                                          • joystick-selection tool
                                          • rpie-art tool
                                          • achievements I made
                                          lostlessL 1 Reply Last reply Reply Quote 0
                                          • lostlessL
                                            lostless @meleu
                                            last edited by

                                            @meleu that was in the original script from mauseberry. never had any issues. interesting that their code just constantly checks the gpio.

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