shutdown utton now writes some syslog
parent
ed85f9a89f
commit
01a6c13db3
|
@ -3,15 +3,18 @@ import RPi.GPIO as GPIO
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
GPIO.setmode(GPIO.BCM)
|
GPIO.setmode(GPIO.BCM)
|
||||||
|
|
||||||
GPIO.setup(buttonpin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
|
GPIO.setup(buttonpin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
print "waiting..."
|
print "waiting..."
|
||||||
|
os.system('logger shutdownbutton waiting for press...')
|
||||||
try:
|
try:
|
||||||
GPIO.wait_for_edge(buttonpin, GPIO.FALLING)
|
GPIO.wait_for_edge(buttonpin, GPIO.FALLING)
|
||||||
print('Button Pressed')
|
print('Button Pressed')
|
||||||
|
os.system('logger shutdownbutton pressen. bye bye')
|
||||||
os.system("shutdown now -h")
|
os.system("shutdown now -h")
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
GPIO.cleanup() # clean up GPIO on CTRL+C exit
|
GPIO.cleanup() # clean up GPIO on CTRL+C exit
|
||||||
|
|
Loading…
Reference in New Issue