Expand button functionality

Short press now toggles wifi. LED will flash 3 times to show the command was received. - wifi will toggle within 30 seconds.
2 second press reboots. LED will turn on to show the command was received.
This commit is contained in:
nagumii 2024-12-23 17:04:05 +02:00
parent b9715b8585
commit d01e497294
3 changed files with 11 additions and 13 deletions

View file

@ -1,11 +1,11 @@
[Unit]
Description=Button Reboot Service
Description=Button Service
After=multi-user.target
[Service]
ExecStart=/usr/local/bin/buttonservice.sh
ExecStart=/usr/local/bin/button.sh
Restart=always
User=femto
User=root
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,8 @@
fi
else
echo "$duration second button press detected. Rebooting."
echo 1 > /sys/class/gpio/gpio34/value;
sudo reboot
fi
fi
done

View file

@ -1,10 +0,0 @@
#!/bin/bash
logger "$(date): Listening for button press on $DEVICE..."
evtest --grab /dev/input/event0 | while read line; do
if echo $line | grep -q "EV_KEY.*value 1"; then
logger "Button pressed, triggering reboot..."
sudo reboot
fi
done