Mausberry Shutdown Script Doesn't Save Metadata
-
@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?
-
@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.
-
@meleu that was in the original script from mauseberry. never had any issues. interesting that their code just constantly checks the gpio.
-
@lostless do they have a github repo or something?
-
@meleu they don't. just the download and install instructions on their website. But heres the script you download and install.
echo '#!/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 sudo poweroff fi done
-
@lostless said in Mausberry Shutdown Script Doesn't Save Metadata:
@meleu killed all switch functionality. As in it no longer functions as a shutdown switch.
is it killing the emulator/ES?
-
@meleu its not doing anything.
-
@lostless did you install
inotify-tools
? -
@meleu yes
-
@lostless OK, let's try with that expensive infinite loop just to check if the
inotifywait
part is bugging the script. Hold on a little... -
@meleu I'm trying my own Frankenste in script (taking the parts that i see may work)
-
@lostless please, try this one:
#!/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 file="/sys/class/gpio/gpio$GPIOpin1/value" while true; do power="$(cat "$file")" if [[ "$power" == 0 ]]; sleep 1 else 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 fi done
-
@meleu your new script is still doing nothing and mine worked just like the 1.2.
-
@lostless helping with this blind coding is very hard. I'm giving up...
-
@meleu sounds good man. it was fun. the 1.2 works fine, a lot better then always losing meta data all the time.
-
@lostless where is this script placed? what directory?
-
@meleu location is /etc/switch.sh
-
@meleu My frankenstein script is working. Thank you so much for giving me insight. I know i didnt contribute anything to the code, but I feel like a kid in the 80/90s, discovering computers before they were made easy to use.
i found you need to give time for retroarch to quit and emulation station to reload before you try quit emulation station. i gave it 12 seconds. 5 was not enough, by the time the emulator quit, emulation station was not fully loaded back in.here is what i came up with
#!/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.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.works 7/27/17 (are we even trying to number this) @lostless figured it out. More time to quit emulator and reload emulation station before shutdown. @cyperghost thank you for initial run. @meleu thank you for your insight emu_command="$(sed -n 4p /dev/shm/runcommand.info)" [[ -n "$emu_command" ]] && pkill -f "${emu_command%% *}" && sleep 12 espid=$( pgrep -f "/opt/retropie/supplementary/.*/emulationstation([^.]|$)" ) # detect PID of ES binary only 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 sudo poweroff fi done
@cyperghost Thank you for the first script up to 1.2.
@hansolo77 give this a try. its working for me quite well. -
@lostless can you try this one:
#!/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 emu_command="$(sed -n 4p /dev/shm/runcommand.info)" [[ -n "$emu_command" ]] && pkill -f "${emu_command%% *}" && sleep 12 espid=$( pgrep -f "/opt/retropie/supplementary/.*/emulationstation([^.]|$)" ) if [ "$espid" ]; then touch /tmp/es-shutdown && chown pi:pi /tmp/es-shutdown kill $espid exit fi sudo poweroff fi done
It's exactly the same script as your Frankenstein, but with a nice indentation. If it works I will try one step further...
I really would like to avoid that loop every single second! -
@hansolo77 said in Mausberry Shutdown Script Doesn't Save Metadata:
Testing v1.5 from here now....
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 validtrue
and going to the bottom of the script to the original poweroff without exiting ES first...You are 100% right.... made a small mistake - I forget to add exit command to break loop! Thank you
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? :)
@lostless - version 1.5 should work now!
Sorry... I forget to exit the loop thanks to @hansolo77 he helped me to detect the bug.Please mates try again with v1.5 of exit script (with working exit command now)
I give you 100% working guarantee on this ;) You maybe have to extend timer.
I would prefer this to @meleu solution because the sleep timer isn't used if there is no emulator running and the PID is detected and stored asThis script can be extended to play and/or control backgroundmusic for ex. because it extracts PID$espid
and$emupid
@meleu Do you think you can break the endless 1 second loop?
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.