Mausberry Shutdown Script Doesn't Save Metadata
-
PID > 0 means it is running or not ;)
Okay than the approach is easy if pkill does not hurt :)pkill -f "$(sed -n 4p /dev/shm/runcommand.info)"
@hansolo77? There is a new toy ;)
Please instead ofpkill retroarch
use line above. Can you please test?
If all proper runs it can be pushed to version 1.3ES is not a victim, it behaves like a sqarehead but with a few tricks it can be calmed down ;)
Knowledge is power and thank you @meleu to share your knowledge with us.I think thats our passion not obsession, that would be bad!
-
Wow guys. My email inbox is spammed. :) I'm actually not too worried about getting it to save if I'm in the middle of a game. That situation rarely comes up, and to my memory only recently while troubleshooting all this. :)
I will test v1.3 (adding the retroarch pkill) here in a little while. I'm suffering a massive migraine. Have had it the last 3 days. Every now and then it act's like it's feeling a little better and I can get some work done with this. I'm honestly thrilled that I've got you guys pulling your hair out on all this and have a working solution already. :)
-
@hansolo77 said in Mausberry Shutdown Script Doesn't Save Metadata:
I'm honestly thrilled that I've got you guys pulling your hair out
Which hair? :-)
-
@hansolo77 Please test like you want
pkill retroarch
works just for libretro-cores, the sniplet of @meleu works with all things that were started throughruncommand.sh
- so it's the more versatile wayWhich hair :-)
nose hair! What an awful torture!
-
The 1.2 script is working great for me as well.
@hansolo77 I've solved the saving issue by having retroarch to check and write to disk the srm files every 10 seconds if its new. Its an option in retroarch under the saving menu. I learned a hard lesson powering off in the middle of a game and losing about an hours worth of gameplay. -
@lostless said in Mausberry Shutdown Script Doesn't Save Metadata:
I learned a hard lesson powering off in the middle of a game and losing about an hours worth of gameplay
Can you share with us what is the exact option for this? I'm highly interested.
I had a similar issue while playing Terranigma after freeing 4 continents. I was playing on my GPD XD (Android device) and left the device in standby but the battery was over. And then the srm file wasn't saved... :( You know, RPGs are very time consuming...
@cyperghost that's why you don't see me talking about Terranigma recently. But I'll try it again!
-
Can you share with us what is the exact option for this? I'm highly interested.
I'm also highly interested
@cyperghost that's why you don't see me talking about Terranigma recently. But I'll try it again!
Do that! I'm just stick in the middle of the game. You need so much time for RPG but it makes real fun.
-
@cyperghost I think I've found it!
The option is
autosave_interval
. Look here: https://github.com/libretro/RetroArch/blob/master/retroarch.cfg#L785300 should be a good value. 300 seconds = 5 minutes
EDIT: via menu it's Settings -> Saving -> SaveRAM Autosave Interval.
-
@meleu that's it. I did some testing a while ago and it only writes a new file if it's been changed. So 10 seconds works good for me.
-
Good stuff! So just to clarify, that's saving the nonvolatile RAM right? Not creating a Save State? Because of RetroAchievments, I typically just leave my RetroArch in Hardcore mode, which disables Saves States and Cheats.
Sorry about last night and my headache. I wasn't fully following the discussion between @cyperghost and @meleu. When I get a chance, I will try it with the command:
pkill -f "$(sed -n 4p /dev/shm/runcommand.info)"
-
@hansolo77 yes just the sram. Not savestates. By default the sram stays in RAM until you exit. This just checks the sram every x seconds and sees if there is a change. If so, it writes to disk.
-
That added line to the script seems to break the script. I added the 1.3 changes (using the original
pkill retroarch > /dev/null 2>&1
bit), then I changed it to thepkill -f "$(sed -n 4p /dev/shm/runcommand.info)"
. For some reason now, whenever I press the power button nothing happens. At first I thought it was because thepkill
command was nested inside theif
statement. When I SSH'd into the system and checkedtop
, ES was no longer running when RetroArch was. So the new additions to the script weren't getting picked up. I moved it (as a test) outsideif
functions. Still nothing happened. I've experimented with doingsudo reboot
from the SSH terminal as well as via ES shutdown (from the menu). In both cases, the power button still doesn't work. I can, however, power the system on from a complete power plug pull via the button, so I know the switch is still good. You sure that's the right command? -
OK, further "looking around"... the original script (v1.2) wasn't working either. So I went back to the unedited v0.0 (the one Mausberry has you install). That one didn't work either! So I checked out the install script, and saw they're adding a line to
rc.local
. I'm not sure what that file is, but when I edited it, it had 2 instances of the script path/etc/switch.sh
in there. I took one out and rebooted. Now the original script is working right. Gonna try putting in the new changes and see if that was my problem.EDIT Still a no-go on that 1.3 edit. :(
EDIT 2 Facepalm - I think it might be a file properties issue now... I rechecked the Mausberry install script and noticed they're doing a
chmod +777
on the script prior to rebooting. Since I already had a working script, I moved it to a backup file before making changes. I saved the changes to a new file and renamed it to be what it should be. But I suspect the+777
isn't there. So I added that bit in the terminal and just rebooted. The system now shuts down correctly (using the 1.2 script). Now testing 1.3.EDIT 3 Ha! That was the trick. But it's not saving the metadata. It might be that it's not giving it enough time to return to ES before cutting the power... When I hit the button, it turns off the emulator, and I see the RunCommand box (haven't set up the launching images yet). At the bottom of the screen there is a line that says "Terminated", then the system turns off..
EDIT 4 I don't think this script in it's current form works well. I tried adding a second to the sleep timer. Then tried to test the script just as is before actually launching a game. The script launches, but the system never shuts down. ES closes, but that's it. I don't know if it's getting hung up on the
sleep
or what. But the only way I can recover is by pulling the plug. With the 2 added (v1.3) lines # commented out, the system fully powers down again. I think there needs to be additional lines of code to include an if/then/else. IF emulator is running, THEN kill and wait, ELSE shutdown ES. But will that even execute if an emulator isn't running? Would it need to read out as "IF emulator, THEN kill emulator and wait, THEN kill ES.. ELSE kill ES"?PS - I'm done for the night. :)
-
So I think it we should provide and maintain v1.2 only!
Get the version for Mausberry circuits shutdowns from hereThank @hansolo77 for testing this
This script will properly shutdown ES and saves it's metadata if you press power button on your mausberry circuit!- Metadata is needed to save scraped games, favorites and last played record upon next reboot
- This script will work if your are in EmulationsStation
- This script will not properly save metadata if you shutdown during gameplay or if your RPi is locked (So return to ES by pressing start+select on your gampad and then shutdown!)
# End Emulationstation if condition of running binary is true # v1.0 07/21/17 by cyperghost - Inital run # v1.1 07/22/17 - Added chown command to set right user permission for creating es-shutdown # v1.2 07/23/17 - Some small improvments, easier to maintain, removed echo, removed else branch # greetings @pjft for his famous favorits and @meleu for the RegEx sniplet espid=$( pgrep -f "/opt/retropie/supplementary/.*/emulationstation([^.]|$)" ) # detect PID of ES binary only if [ "$espid" ]; then # Condition: PID is not equal 0 or empty then use ES shutdown touch /tmp/es-shutdown && chown pi:pi /tmp/es-shutdown #v1.1 Change file permission of es-shutdown to user:group pi:pi kill $espid #v1.2 use kill@detected PID - easier to maintain now! exit fi # End Emulationstation if condition of running binary is true
-
EXPERIMENTAL!!!
Converted from @meleu to kill all emulators
It worked (saved recently used games) for me in SSH but I've no chance to test >> lack of mausberry!# End Emulationstation if condition of running binary is true (Shotgun-version - no support!) # v1.0 07/21/17 by cyperghost - Inital run # v1.1 07/22/17 - Added chown command to set right user permission for creating es-shutdown # v1.2 07/23/17 - Some small improvments, easier to maintain, removed echo, removed else branch # v1.4 07/25/17 - Shotgun method to terminate all launchs by runcommand (not maintained, use v1.2 for support) # greetings @pjft for his famous favorits and @meleu for the RegEx sniplet espid=$( pgrep -f "/opt/retropie/supplementary/.*/emulationstation([^.]|$)" ) # detect PID of ES binary only if [ "$espid" ]; then #### Experimental part #### IFS=" " set – $( sed -n 4p /dev/shm/runcommand.info ) > /dev/null 2>&1 pkill $2 && sleep 4 # v1.4 Sleeptimer to give ES chance to save XML filestate (untestested) #### Experimental part #### touch /tmp/es-shutdown && chown pi:pi /tmp/es-shutdown # v1.1 Change file permission of es-shutdown to user:group pi:pi kill $espid # v1.2 use kill@detected PID - easier to maintain now! exit fi
-
@cyperghost some notes
- the indentation can be improved :)
- the default
IFS
is space, tab and newline. I think there's no need to set it as space - I'm not getting the reason why you are messing with the
set
command (unnecessary complexity)...
the suggested command doesn't work for you?
pkill -f "$(sed -n 4p /dev/shm/runcommand.info)"
-
@meleu yes
pkill -f "$(sed -n 4p /dev/shm/runcommand.info)"
Does not work. So you need to extract just binary call... I tested with retroarch, glide64 and zdoom. All were prober working byset
-command -
@cyperghost said in Mausberry Shutdown Script Doesn't Save Metadata:
@meleu yes
pkill -f "$(sed -n 4p /dev/shm/runcommand.info)"
Does not work.weird. I'm not able to test on my actual RetroPie, but look the test I've made:
[PROMPT]$ sleep 1000 & [1] 8648 [PROMPT]$ cat test.info 1st line 2nd line 3rd line sleep 1000 bla bla bla [PROMPT]$ pkill -f "$(sed -n 4p test.info)" [1]+ Terminated sleep 1000
But I noticed an issue when the file to look for the 4th line doesn't exist... then my suggestion is to use this
[[ -f /dev/shm/runcommand.info ]] && pkill -f "$(sed -n 4p /dev/shm/runcommand.info)"
Can you test it on a real RetroPie setup?
-
@meleu Not now ... Have to work :)
Cya mate! -
@cyperghost I found the problem: that line from
runcommand.info
has some double quotes wich is confusing thepkill
. Here's my current solution:rcinfo=/dev/shm/runcommand.info [[ -f "$rcinfo" ]] && pkill -f -9 "$(sed -n 4p "$rcinfo" | cut -d' ' -f1)"
I tested on my retropie here and it seems to work. Please test it when you have a chance.
Cheers!
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.