supersirlink
Participant
Post count: 42

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