Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
17 lines (12 sloc) 423 Bytes
#!/usr/bin/env python3
from gpiozero import Button
from signal import pause
import os, sys
offGPIO = int(sys.argv[1]) if len(sys.argv) >= 2 else 21
holdTime = int(sys.argv[2]) if len(sys.argv) >= 3 else 6
# the function called to shut down the RPI
def shutdown():
os.system("sudo poweroff")
btn = Button(offGPIO, hold_time=holdTime)
btn.when_held = shutdown
pause() # handle the button presses in the background
You can’t perform that action at this time.