Mausberry Shutdown Script Doesn't Save Metadata
-
@hansolo77 Yes - I made finally some cleanups to code you may look into v1.56 @meleu discovered there also a small pitfall and as I already made some changes I established a precheck if file exists (runcommand.info) to just trap errormessage while sed-command is reading the file :)
So it's better to recheck again - don't fear - the code is working.
I think it's also in the mind of @meleu and definatly my last work on this piece. I learned a lot from this. The error accourd as I used the PID detector and no emulator was started before. So sed-command gives out error ... This is just cosmetical but now it's perfect. -
I see you added:
if [[ -e "/dev/shm/runcommand.info" ]]; then
I'm on my way out the door right now, but I will try to test this latest version tonight!
-
@hansolo77 Yes and a bit more but this has been impossible without the help from @meleu
if [[ -e "/dev/shm/runcommand.info" ]]; then emupid="$(sed -n 4p /dev/shm/runcommand.info | tr -d '\\"' | tr '^$[]*.()|+?{}' '.')" emupid="$(pgrep -f "$emupid")" fi
-
Results from testing 1.56 (with @meleu fix)
- Shutdown from inside ES (normal)
PASS - Shutdown from inside ES (during screensaver)
PASS - Shutdown from inside a game (RetroArch)
PASS - Shutdown from inside a game (non-RetroArch (SuperMarioWar))
PASS (although I still thinksleep
is too long)
Cha-Ching! At least for me. I still don't have ScummVM installed to verify @meleu's fix, but at least I can confirm the additions don't break anything else. :)
EDIT
Did some further experimenting on my own.. Droppedsleep
down to 7, then 5, then 4, then 3, then 2, then 1. All testing verified proper shutdown and metadata saving. Doesn't take NEAR as long to start shutting down after closing out of an emulator now! With 2 seconds, ES barely has enough time to load back up before shutdown. The video snap runs about 2-3 frames before the menu starts rendering, then the system powers off. With 1 second, all you get is a brief little glimpse of the menu starting to load then power off (before the video starts). I then tried to #comment out the entire&& sleep 1
bit. The results are that I get theRunCommand
screen and the word "Terminated" at the bottom. ES never loads back up at all, and the metadata does NOT save. So we definitely need thatsleep 1
at least. I also tested withsleep .5
but that didn't work either, same results as being #commented out. So now I'm using this:#!/bin/bash #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 while [ 1 = 1 ]; do power=$(cat /sys/class/gpio/gpio$GPIOpin1/value) if [ $power = 0 ]; then sleep 1 else # End Emulationstation if condition of running binary is true (v1.56) # 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.5 07/27/17 - Great step to exit ES even if emulators is running by runcommand.sh are started # v1.55 07/29/17 - all kudos go to @meleu for his alltime genious RegEx hack! # v1.56 07/30/17 - All emulators will be detected. This is a full functional code equal to developing v1.7 # v1.7 is in work flow - This will be cleaner and better coded and is better to maintain # I just checked with SSH command - it saved my metadata! Maybe you need to extend sleeptimer! # greetings @pjft for his famous favorits and @meleu for his RegEx sniplets and his constant help! espid="$(pgrep -f "/opt/retropie/supplementary/.*/emulationstation([^.]|$)")" if [[ -e "/dev/shm/runcommand.info" ]]; then emupid="$(sed -n 4p /dev/shm/runcommand.info | tr -d '\\"' | tr '^$[]*.()|+?{}' '.')" emupid="$(pgrep -f "$emupid")" fi if [ "$emupid" ]; then kill $emupid && sleep 1 fi if [ "$espid" ]; then touch /tmp/es-shutdown && chown pi:pi /tmp/es-shutdown kill $espid exit fi # End Emulationstation if condition of running binary is true (v1.56) sudo poweroff fi done
I did, however, notice that if I press the power button while the game has a few moments to actually load up (like in the in-game demo, rather than opening credits) it didn't load ES on 1 second.. it just did the
RunCommand
with "Terminated". So maybe the 1 second only works "right away"? Then again.. I just tested again with the same game while waiting longer and it worked, then it worked again with a different game while waiting. So maybe that was just a onetime glitch. Still, 1 time is enough to lose all your metadata... Has this come up before? I can't imagine it having been, since this is the first exposure to this script. But does it sound like something that could happen.. pressing the button after a longer period has a different out come than pressing it right after starting a game? In any case, I just tested with a 3rd game, and this time a non-RetroArch one. It still works great at 1 second.I dunno, you think I should just use 2 and play it safe?
- Shutdown from inside ES (normal)
-
@hansolo77 said in Mausberry Shutdown Script Doesn't Save Metadata:
I dunno, you think I should just use 2 and play it safe?
IMHO yes.
-
Really nice work guys. Will try later this as well!
Is v1.7 still under development? Willing to test of course!
-
@barrymossel I'm using 1.7 and it working fine.
-
@lostless said in Mausberry Shutdown Script Doesn't Save Metadata:
@barrymossel I'm using 1.7 and it working fine.
Can you post a link to the script you're naming as 1.7?
Or maybe paste it in ghostbin...
-
@barrymossel said in Mausberry Shutdown Script Doesn't Save Metadata:
Is v1.7 still under development?
This "development" is more about testing than writing code. I would love to have this device to make more tests. I tried some experimentations with @lostless via IRC but it was late night... If you find me at IRC some day feel free to contact me.
If I find some time I'll write what tests I would like to do...
-
@meleu I assumed i was using 1.7. It's what ever the last one @cyperghost posted.
-
@meleu said in Mausberry Shutdown Script Doesn't Save Metadata:
@barrymossel said in Mausberry Shutdown Script Doesn't Save Metadata:
Is v1.7 still under development?
This "development" is more about testing than writing code. I would love to have this device to make more tests. I tried some experimentations with @lostless via IRC but it was late night... If you find me at IRC some day feel free to contact me.
If I find some time I'll write what tests I would like to do...
Ah, I thought you didn't figure out how to work around the loop yet. I will check in IRC later!
-
@barrymossel we didn't. For some reason the inotify was not reading the change on the gpio. So something is up. What's weird though, is when we manually told the pi there was a change to the gpio, the script worked.
-
@lostless @barrymossel
The version 1.56 could be considerd as 1.70 without the inotify-part. It held all code pieces to detect emulators and to finish them and make ES shutdown properly. It uses the 1.0second endless loop that was introduced in the mausberry script.So @meleu is working on 1.70 to break the loop.
I'm also interested in 1.70 not using it as power switch rather as a generell switch. I plan to make a small build and this code would improve much.So meleu will "release" two version.
- A shutdown script with better GPIO detection (inotify)
- A shutdown script with 1.0sec loop as introduced in mausberry
Why two versions? Simply the inotify package isn't preinstalled!
We can all be happy to have one so extrem gifted coder here in our forum.
Thank you meleu!Myself got's only a long breath and is willing to learn something new.
-
Would using a script like this be possible with the retropie powerblock?
-
Seems so.... But please .... we create annother thread
-
v1.56 works for me. SCUMMVM shuts down immediately without exiting to ES. Is that correct?
-
@barrymossel the script is supposed to exit back to es then shut down. Check with other emulators and see if it does that. If not, something is wrong
-
Only ScummVM. Probably because than one was an exception. But I don't know whether this would be expected behavior for ScummVM or not. Guess @meleu will tell ;)
-
@barrymossel Please can you use PID detector and check PIDs displayed?
Useps -a
and check PIDs? -
@barrymossel and post the exact script you're using on ghostbin.com or something.
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.