From 88a54148c9be32b09559dc74910f1496b24e3421 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 27 Feb 2022 23:39:24 +0100 Subject: Renamed buttonctld to buttond. --- buttonctl/buttond.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 buttonctl/buttond.py (limited to 'buttonctl/buttond.py') diff --git a/buttonctl/buttond.py b/buttonctl/buttond.py new file mode 100644 index 0000000..26878f1 --- /dev/null +++ b/buttonctl/buttond.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 From e6ef9ed4a3129da1e449f4f4f5e0d7719b8b04c5 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 27 Feb 2022 23:42:04 +0100 Subject: Run systemctl daemon-reload at the end of make install. --- buttonctl/buttond.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'buttonctl/buttond.py') diff --git a/buttonctl/buttond.py b/buttonctl/buttond.py index 26878f1..a49b4e4 100644 --- a/buttonctl/buttond.py +++ b/buttonctl/buttond.py @@ -4,11 +4,13 @@ import RPi.GPIO as GPIO import subprocess +print ('waiting for button presses'); + 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') +print ('button pressed, shutting down') subprocess.call(['ledctl', 'boot'], shell=False) -- cgit v1.2.3 From be644b94dc95c48608a5614a3de2f02d62321016 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 27 Feb 2022 23:50:47 +0100 Subject: Print buttond error messages to stderr. --- buttonctl/buttond.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'buttonctl/buttond.py') diff --git a/buttonctl/buttond.py b/buttonctl/buttond.py index a49b4e4..661b2f6 100644 --- a/buttonctl/buttond.py +++ b/buttonctl/buttond.py @@ -2,15 +2,16 @@ import RPi.GPIO as GPIO import subprocess +import sys -print ('waiting for button presses'); +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 ('button pressed, shutting down') +print ('Soft button pressed, shutting down...', file=sys.stderr) subprocess.call(['ledctl', 'boot'], shell=False) -- cgit v1.2.3