From ba5673c7e1c4c2334adecd44e75ab9d1e9ba0183 Mon Sep 17 00:00:00 2001 From: Ingar Date: Sun, 27 Feb 2022 11:59:40 +0100 Subject: Added script to handle soft button events. --- buttonctl/buttonctl.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 buttonctl/buttonctl.py (limited to 'buttonctl/buttonctl.py') diff --git a/buttonctl/buttonctl.py b/buttonctl/buttonctl.py new file mode 100644 index 0000000..26878f1 --- /dev/null +++ b/buttonctl/buttonctl.py @@ -0,0 +1,16 @@ +#!/usr/bin/python + +import RPi.GPIO as GPIO +import subprocess + + +GPIO.setmode(GPIO.BCM) +GPIO.setup(26, GPIO.IN, pull_up_down=GPIO.PUD_UP) +GPIO.wait_for_edge(26, GPIO.FALLING) + +print ('button pressed') + +subprocess.call(['ledctl', 'boot'], shell=False) + +subprocess.call(['shutdown', '-h', 'now'], shell=False) + -- cgit v1.2.3