blob: 661b2f6af946d76a7f65a5bbcbdb4b5dd7589db5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
#!/usr/bin/python
import RPi.GPIO as GPIO
import subprocess
import sys
print ('Watching soft button GPIO26 for button presses...', file=sys.stderr);
GPIO.setmode(GPIO.BCM)
GPIO.setup(26, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.wait_for_edge(26, GPIO.FALLING)
print ('Soft button pressed, shutting down...', file=sys.stderr)
subprocess.call(['ledctl', 'boot'], shell=False)
subprocess.call(['shutdown', '-h', 'now'], shell=False)
|