Mausberry Shutdown Script Doesn't Save Metadata
-
@lostless please, give me a few minutes and I'll tweak the script v1.2 a little and post it to you try.
-
@lostless please, install
inotify-tools
:sudo apt-get install inotify-tools
and then try the script below:
#!/bin/bash # Before using this script you need to install inotify-tools: # # sudo apt-get install inotify-tools # # I'm just trying to help with the script logic here. # I DON'T HAVE A MAUSEBERRY AND DIDN'T TEST THE GPIO STUFF HERE! # ######################################################### # U S E I T A T Y O U R O W N R I S K ! ! ! # ######################################################### # # meleu - July/2017 # kudos for @cyperghost , who is very persistent in help you guys! :-) #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 inotifywait -qq -e modify "$file" ; do power="$(cat "$file")" [[ "$power" == 0 ]] && continue 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 done
-
@meleu Im giving it a shot. I really don't want to reconfigure my pi, but oh what the heck. Ive only had to reconfigure 10 times or so. whats another for the most perfect script for mauseberry (or other switch) users.
-
@lostless I edited the script, be sure to get the current one!
-
@meleu i saw that. whew.
-
@meleu killed all switch functionality. As in it no longer functions as a shutdown switch.
-
@lostless OK. I'll try a little further...
-
@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.
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.