summaryrefslogtreecommitdiff
path: root/buttonctl
diff options
context:
space:
mode:
authorIngar <ingar@telenet.be>2022-08-25 00:42:19 +0200
committerIngar <ingar@telenet.be>2022-08-25 00:42:19 +0200
commitfbacdc78311265078f0baf7c1f8ddee4ec75a5c0 (patch)
tree9a3607879722a873ec68740a6aaf6be4f644d53c /buttonctl
parentc4193ba7e4fac1dfeae28e629f248ea97be43c15 (diff)
parentbe644b94dc95c48608a5614a3de2f02d62321016 (diff)
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'buttonctl')
-rw-r--r--buttonctl/Makefile4
-rw-r--r--buttonctl/buttond.py (renamed from buttonctl/buttonctl.py)5
-rw-r--r--buttonctl/systemd/buttond.service (renamed from buttonctl/systemd/button.service)2
3 files changed, 9 insertions, 2 deletions
diff --git a/buttonctl/Makefile b/buttonctl/Makefile
new file mode 100644
index 0000000..7b8c933
--- /dev/null
+++ b/buttonctl/Makefile
@@ -0,0 +1,4 @@
+install:
+ install -m 744 buttond.py /usr/bin/buttond
+ install -m 644 systemd/buttond.service /etc/systemd/system/buttond.service
+ systemctl daemon-reload
diff --git a/buttonctl/buttonctl.py b/buttonctl/buttond.py
index 26878f1..661b2f6 100644
--- a/buttonctl/buttonctl.py
+++ b/buttonctl/buttond.py
@@ -2,13 +2,16 @@
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 ('button pressed')
+print ('Soft button pressed, shutting down...', file=sys.stderr)
subprocess.call(['ledctl', 'boot'], shell=False)
diff --git a/buttonctl/systemd/button.service b/buttonctl/systemd/buttond.service
index e77edd2..e1975c9 100644
--- a/buttonctl/systemd/button.service
+++ b/buttonctl/systemd/buttond.service
@@ -4,7 +4,7 @@ After=local-fs.target
[Service]
Type=simple
-ExecStart=/usr/bin/buttonctl
+ExecStart=/usr/bin/buttond
[Install]
WantedBy=multi-user.target