Skip to content

Instantly share code, notes, and snippets.

@massimomusante
Last active June 3, 2018 13:51
Show Gist options
  • Save massimomusante/fbc2cf5170be469f7cecb96963f61eae to your computer and use it in GitHub Desktop.
Save massimomusante/fbc2cf5170be469f7cecb96963f61eae to your computer and use it in GitHub Desktop.
Raspberry PI listen for shutdown script
#!/usr/bin/env python
import RPi.GPIO as GPIO
import subprocess
GPIO.setmode(GPIO.BCM)
GPIO.setup(3, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.wait_for_edge(3, GPIO.FALLING)
subprocess.call(['shutdown', '-h', 'now'], shell=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment