Mausberry Shutdown Script Doesn't Save Metadata
-
By all means. If a prettier solution can be had, it's for the better of everybody. Maybe we can even send a message over to the folks at Mausberry: "Hey, you guys should update your 'setup' webpage to include a blurb about our new script working if your goal is to use the circuit in a RetroPie setup". Of course, you're not their yet if you still wanna tinker.
And yeah, so long as my seedbox is online, I'm always in that chat forum (along with a dozen or so others). I do a lot of idlerpg for some of my private torrent trackers, and like to keep chatrooms open that I go to for help. Most of the time it's @Rookervik chatting up in there, but every now and then I see names I recognize like @cyperghost , @herb_fargus , @lilbud :)
-
@hansolo77 said in Mausberry Shutdown Script Doesn't Save Metadata:
Most of the time it's @Rookervik chatting up in there, but every now and then I see names I recognize like @cyperghost , @herb_fargus , @lilbud :)
It's only ever a few people chatting even though 70+ people could be in the room. It's usually quiet the rest of the time
-
@meleu said in Mausberry Shutdown Script Doesn't Save Metadata:
Feel free to mark it as solved if it works for you. I am (was?) just trying to find a strong solution, for every scenario.
I think so, but I'm pretty sure that your solution (ScummVM fix) is already in usage by @hansolo77 - I asked you (yesterday is wrong!) for a few hours of using the sniplet. I'm just reading that more and more people rip out parts of these scripts for different other usecases.
@meleu About giving the user the best experience: Add the latest version(s) posted in this topic to the "Usefull topic index". I think most (mausberry) people find it usefull. There are still other selling products (Powerblock PetRetBlock or some selfmade things). Maybe the Pi4 (maybe 2018 but rather 2019) will contain a power switch.
Out of this is code pieces I created a PID detector for ES and all emulators Garbage: PID Detector. It gives report of an running emulator and detects running ES and output both PID numbers. Out of this it is pretty easy to perform a simple escpae keypress just
kill $espid
. So we have full control over ES ... we can restart ES, quit ES, system reboot and system shutdown now :)@hansolo77 might you recheck if your script contains this line? If yes then it's a working version equal to @meleus upcoming, without the optimzing in sleep timer.
emupid="$(sed -n 4p /dev/shm/runcommand.info | tr -d '\\"' | tr '^$[]*.()|+?{}' '.')"
Otherwise there might be issues with some emulators like ScummVM.About the telling mausberry to optimzie their bash script. Well no.... RetroPie and ES is just a special usecase. The mausberry script is working 100% in all usecases without installing an extra tool. So to follow unix philosopie - keep it simple and working and one tool for one usecase.
As me and @meleu (afaik) do not even possess a mausberry switch it's a bit difficult to test such scripts. We could run them and give anecho 1 > /sys...
but then we still do not have insights about user permission... and I think we are the latest man on earth who say. "Do what I say...", we just make suggestions.At last I have to say thank you to meleu for his constant help in caveeats and making suggestions. This is really a nice guy.
Download of latest version 1.56 is here
-
@cyperghost - Yes I am using the version with that line:
emupid="$(sed -n 4p /dev/shm/runcommand.info | tr -d '\\"' | tr '^$[]*.()|+?{}' '.')"
-
@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?
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.