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

    METADATA not saving - Favorites will never remain tagged

    Scheduled Pinned Locked Moved Help and Support
    nespi casemetadata issuesfavoritesshutdown scriptgameslist.xml
    121 Posts 7 Posters 17.5k 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 @Semper 5
      last edited by cyperghost

      @semper-5 Did you insert the text via nano command? and did you made it executable with chmod +x /home/pi/RetroPie/scripts/switch.sh

      S 1 Reply Last reply Reply Quote 0
      • S
        Semper 5 @cyperghost
        last edited by

        @cyperghost yes. but I'm looking at the same file with the same content in both nano and text editor on WinSCP

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

          @semper-5 Close the WINSCP viewer, or close WINSCP at all... and just use the CLI provided by putty. WINSCP sometimes uses it's cache to display files. Then on reboots/restarts it messes the system up with old files.

          I need the info if the script is working in the basic variant - just for tomorrow (going to bed).... because then I can provide a full working solution with better handling of the emulator calls ;)

          S 1 Reply Last reply Reply Quote 0
          • S
            Semper 5 @cyperghost
            last edited by Semper 5

            @cyperghost yeah tell me about it I'm cursing at my computer right now and I'm still at work past 5pm lol!

            so I am using ONLY CLI (using F4). no putty no winscp.
            I can see the script. I can edit the info and see the content. but when I execute it using sudo /home/pi/RetroPie/scripts/switch.sh I get

            No such file or directory

            Wondering if I should bump up to the 4.4 :/

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

              @semper-5 I think it doesn't matter if it's 4.4 or 4.3

              With CLI I don't mean to enter terminal by quit ES. Without ES running in background the script will do nothing. So just use SSH and putty to edit the files. Maybe it is also a good idea to start the script through SSH (so you can read error messages)!

              Can you check if I setted the right GPIOs? As I said in my example yesterday... Without the POLOLU I was able to trigger right as I used a wire and just connected GPIO24 directly to PIN1 (3,3V) ... Proper shutdown.

              So I guess the detection routines of ES and EMULATORS still work. But I don't know the switch shematic of your build.

              Stupid question: Did you create folder scripts within your home directory?

              S 1 Reply Last reply Reply Quote 0
              • S
                Semper 5 @cyperghost
                last edited by

                @cyperghost I tried moving and recreating the script in 5 various places but it keeps coming back as command not found
                this is just getting crazy...i can see it sitting there smiling at me but saying "nope, not gonna do it"

                PS: there's no stupid questions when dealing with a dummy lol

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

                  @semper-5 hmmm and if you try sudo bash switch.sh
                  I changed the script again to view status message!

                  S 1 Reply Last reply Reply Quote 0
                  • J
                    julenvitoria Banned
                    last edited by

                    Hi guys! I'm trying to close ensurely saving metadata with an script... @cyperghost is your script doing this? Could the script be valid to power off with a generic button?

                    Thanks in advance

                    1 Reply Last reply Reply Quote 0
                    • S
                      Semper 5 @cyperghost
                      last edited by

                      @cyperghost said in METADATA not saving - Favorites will never remain tagged:

                      @semper-5 hmmm and if you try sudo bash switch.sh
                      I changed the script again to view status message!

                      I'm getting something new. and this is on a totally fresh image with nothing but the button script and yours.

                      this is the output when running your script:
                      switch.sh: line 17: echo: write error: Device or resource busy
                      switch.sh: line 19: echo: write error: Device or resource busy

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

                        @semper-5 said in METADATA not saving - Favorites will never remain tagged:

                        I'm getting something new. and this is on a totally fresh image with nothing but the button script and yours.
                        this is the output when running your script:
                        switch.sh: line 17: echo: write error: Device or resource busy
                        switch.sh: line 19: echo: write error: Device or resource busy

                        Well... "Button script"?
                        Then it's clear whats happening. The Button script and "my" script are using the same GPIOs. Please disable the Button script and try again ;) We are getting closer :)

                        @julenvitoria
                        Yes it works with a generic button. Therefore comment all lines that contain $gpiopin2 - these aren't needed. But it's not a well written one. I just want to find out if I'm on the right track with this to use the POLOLU device.

                        S 1 Reply Last reply Reply Quote 0
                        • S
                          Semper 5 @cyperghost
                          last edited by Semper 5

                          @cyperghost more developments, still just cuts the power. and this is the only script I'm running on a fresh image.

                          Output:
                          switch.sh: line 10: $'\r': command not found
                          switch.sh: line 13: $'\r': command not found
                          switch.sh: line 16: $'\r': command not found
                          : Permission denied /sys/class/gpio/export
                          : No such file or directoryass/gpio/gpio24
                          : Permission denied /sys/class/gpio/export
                          : No such file or directoryass/gpio/gpio25
                          : No such file or directoryass/gpio/gpio25
                          switch.sh: line 22: $'\r': command not found
                          cat: '/sys/class/gpio/gpio24'$'\r''/value': No such file or directory
                          switch.sh: line 26: $'\r': command not found
                          switch.sh: line 46: syntax error near unexpected token `fi'

                          'witch.sh: line 46: `fi

                          mituM 1 Reply Last reply Reply Quote 0
                          • mituM
                            mitu Global Moderator @Semper 5
                            last edited by

                            @semper-5 You copied the contents of the script in Notepad by any chance ? Use Notepad++ to create/edit the scripts in Windows and set the line endings to Unix (LF), Notepad saves with Win/DOS line endings (the extra \r character in the script file).

                            S 1 Reply Last reply Reply Quote 1
                            • S
                              Semper 5 @mitu
                              last edited by Semper 5

                              @mitu yup that's what I've been using the whole time (Notepad ++)
                              I've made scripts with no problems many times before. but its just getting hung up on this one

                              anyway I can get this script in RAW? I could clear up just a few of the errors but not the rest. :/

                              cyperghostC J 2 Replies Last reply Reply Quote 0
                              • cyperghostC
                                cyperghost @Semper 5
                                last edited by cyperghost

                                @semper-5 The best way would be to edit with SSH connection and nano.

                                use putty, don't use WINSCP

                                1. cd /home/pi/RetroPie/scripts
                                  1.1 if directory scripts does not exists use mkdir /home/pi/RetroPie/scripts
                                  1.2 then try again with cd /home/pi/RetroPie/scripts
                                2. rm switch.sh this will remove script
                                3. nano switch.sh copy text from code box below
                                  3.1 After inserting code with left mouse button
                                  3.2 Press CTRL+X and press Y to save script
                                4. chmod +x switch.sh makes script executable
                                5. sudo ./switch.sh & to start script in background with root privileges ;)

                                switch.sh CODEBOX

                                #!/bin/bash
                                # End Emulationstation if condition of running binary is true (v1.599)
                                # v1.0 07/21/17 by cyperghost - Inital run 
                                # v1.5 07/27/17 - Great step to exit ES even if emulators is running by runcommand.sh are started // meleu
                                # v1.56 07/30/17 - All emulators will be detected. // meleu
                                # v1.58 08/02/17 - generel method: Use PPID to detect child PIDs now (ScummVM fix) // cyperghost
                                # v1.595 11/14/17 - Inserted newest emucall detection // meleu
                                # v1.599 04/18/18 - NESPI case
                                # v1.6 04/20/18 - added kill -9 to terminate emulators // julenvitoria
                                # greetings @pjft for his famous favorits and @meleu for his RegEx sniplets and his constant help! 
                                
                                #this is the GPIO pin connected to POWER SWITCH
                                GPIOpin1=24
                                
                                #this is the GPIO pin connected to POWER ON CONTROL
                                GPIOpin2=25
                                
                                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
                                
                                power=$(cat /sys/class/gpio/gpio$GPIOpin1/value)
                                [[ $power == 0 ]] && switchtype="1" #Not a momentary button
                                [[ $power == 1 ]] && switchtype="0" #Momentary button
                                
                                until [[ $power == $switchtype ]]; do
                                    power=$(cat /sys/class/gpio/gpio$GPIOpin1/value)
                                    sleep 1
                                done
                                # Detect PID or EMULATOR NAMES
                                emucall="$(sed '4!d; s/\([\\"]\|[[:alnum:]_]\+=[^ ]* \)//g; s/[][(){}^$*.|+? ]/\\&/g' /dev/shm/runcommand.info)"
                                espid="$(pgrep -f "/opt/retropie/supplementary/.*/emulationstation([^.]|$)")"
                                
                                echo "Button Pressed: $power - Switchtype: $switchtype"
                                echo "ES-PID: $espid"
                                sleep 5
                                
                                # Handle calls and send TERM signal
                                
                                if [[ -n "$emucall" ]]; then
                                    emupid="$(pgrep -f "$emucall" | tr '\n' ' ')"
                                    pkill -P "$(echo $emupid | tr ' ' ',')"
                                    kill -9 "$emupid"
                                    sleep 4
                                fi    
                                
                                if [[ -n "$espid" ]]; then
                                    touch /tmp/es-shutdown && chown pi:pi /tmp/es-shutdown
                                    kill "$espid"
                                    exit
                                fi
                                
                                echo "Script terminated not by ES!"
                                
                                1 Reply Last reply Reply Quote 0
                                • J
                                  julenvitoria Banned @Semper 5
                                  last edited by

                                  @semper-5 It's very strange... for example lines 10, 13, 16, 22 and 26 are blank... It works for me but not in the totality of the emulators.

                                  @cyperghost As I mentioned it really works for me, but not in the totality of the emulators... For example it works with retroarch and advancemame but doesn't work with pifba, pcsx-rearmed or mame4all. If I try the commands separately pgrep -f doesn't detect this emulators... pgrep -f "$emucall" doesn't show any pid. Any suggestion for detect the emulators properly?

                                  Thanks

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

                                    @julenvitoria Thanks for the headup. As I wrote this is just a basic script! meleu is the RegEx wizard out here. I changed codebox.... please try again.
                                    I added emupid="$(pgrep -f "$emucall" | tr '\n' ' ')" pkill -P "$(echo $emupid | tr ' ' ',')"
                                    PS: That are the outfindings of @meleu

                                    I'm working on annother emulator detection - Shutdown script some input for better emulator detection

                                    The errors @Semper-5 descripes are caused because these "empty" lines contain Carriage Return (CR) character (0x0D, \r) ... Windows uses linefeed (LF) and carrige return (CR) for creating a new line.

                                    1 Reply Last reply Reply Quote 0
                                    • J
                                      julenvitoria Banned
                                      last edited by

                                      @cyperghost said in METADATA not saving - Favorites will never remain tagged:

                                      emupid="$(pgrep -f "$emucall" | tr '\n' ' ')" pkill -P "$(echo $emupid | tr ' ' ',')"

                                      Hi! I tried your new code but don't work with pifba nor mame4 all. However it worked with pcsx-rearmed emulator. I tried kill -9 "$emupid" and then it works. I dont know if it is advisable or not to do this. If you know any other way I would appreciate it.

                                      Thanks!

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

                                        @julenvitoria said in METADATA not saving - Favorites will never remain tagged:

                                        @cyperghost said in METADATA not saving - Favorites will never remain tagged:

                                        emupid="$(pgrep -f "$emucall" | tr '\n' ' ')" pkill -P "$(echo $emupid | tr ' ' ',')"

                                        Hi! I tried your new code but don't work with pifba nor mame4 all. However it worked with pcsx-rearmed emulator. I tried kill -9 "$emupid" and then it works. I dont know if it is advisable or not to do this. If you know any other way I would appreciate it.

                                        Thanks!

                                        Really don't know why this is happening. I just copied some text parts.
                                        But you may test this script here, please?
                                        All you have to do is to copy from textbox into a bashfile. Maybe emu_shutdown.sh, make it executable with chmod +x emu_shutdown.sh and execute it via SSH if an emulator is running?

                                        Maybe you will get better results then? It will only terminate emulators, not more not less.

                                        1 Reply Last reply Reply Quote 0
                                        • J
                                          julenvitoria Banned
                                          last edited by julenvitoria

                                          @cyperghost Hi, I tried your emulator detector too and the result was the same more or less. There were some emulators that dont stop... If you prefer I could write you throug the other thread.

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

                                            @julenvitoria Thanks! You are right the signal levels are ignored by some emulators.
                                            I would suggest to use kill -9 <PID>

                                            I will update both scripts. So you see - once again something new explored .... ;)

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