Files
raspberry_scripts/button_control.sh
2026-01-27 21:33:04 +01:00

22 lines
440 B
Bash
Executable File

#!/bin/bash
source /opt/raspberry_scripts/led_config.conf
while true; do
gpiomon --num-events=1 --rising $CHIP $BTN_LINE > /dev/null
START_TIME=$(date +%s)
while [ $(gpioget $CHIP $BTN_LINE) -eq 1 ]; do
sleep 0.1
done
END_TIME=$(date +%s)
DURATION=$((END_TIME - START_TIME))
if [ $DURATION -ge 5 ]; then
reboot
elif [ $DURATION -ge 0 ]; then
poweroff
fi
done