You've already forked Geekwom-NASPi-Daemon
Inital Commit
All checks were successful
Geekwom NASPi Daemon / Geekwom NASPi Daemon [arm64] (push) Successful in 10s
All checks were successful
Geekwom NASPi Daemon / Geekwom NASPi Daemon [arm64] (push) Successful in 10s
This commit is contained in:
42
root/usr/lib/geekworm-naspi/button
Normal file
42
root/usr/lib/geekworm-naspi/button
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
|
||||
###
|
||||
#
|
||||
# Options Section
|
||||
#
|
||||
###
|
||||
|
||||
set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
|
||||
###
|
||||
#
|
||||
# Runtime Environment
|
||||
#
|
||||
###
|
||||
|
||||
/usr/bin/gpioset '0' '17'='1'
|
||||
|
||||
while [ 1 ]; do
|
||||
SIGNAL=$(/usr/bin/gpioget '0' '4')
|
||||
if [ "${SIGNAL}" -eq '0' ]; then
|
||||
/usr/bin/sleep '0.2s'
|
||||
else
|
||||
PULSE=$(/bin/date '+%s%N' | /usr/bin/cut '-b1-13')
|
||||
while [ "${SIGNAL}" -eq '1' ]; do
|
||||
/usr/bin/sleep '0.02s'
|
||||
if [ $(($(/bin/date '+%s%N' | /usr/bin/cut '-b1-13')-${PULSE})) -gt '600' ]; then
|
||||
/usr/sbin/poweroff
|
||||
exit 0
|
||||
fi
|
||||
SIGNAL=$(/usr/bin/gpioget '0' '4')
|
||||
done
|
||||
if [ $(($(/usr/bin/date '+%s%N' | /usr/bin/cut '-b1-13')-${PULSE})) -gt '200' ]; then
|
||||
/usr/sbin/reboot
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user