Homepage › Forums › RetroPie Project › Everything else related to the RetroPie Project › Stop/Start process when launching rom › Reply To: Stop/Start process when launching rom
01/13/2014 at 02:28
#4115
Participant
I was wondering that myself, not sure exactly how to do that…
Or if there was a better way to watch for the pins… The original is a bash script:
#!/bin/bash
#this is the GPIO pin connected to the lead on switch labeled OUT
GPIOpin1=22
#this is the GPIO pin connected to the lead on switch labeled IN
GPIOpin2=14
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