From d01e49729419b1e76869417fdaf7e83f06d47ba9 Mon Sep 17 00:00:00 2001 From: nagumii Date: Mon, 23 Dec 2024 17:04:05 +0200 Subject: [PATCH] Expand button functionality Short press now toggles wifi. LED will flash 3 times to show the command was received. - wifi will toggle within 30 seconds. 2 second press reboots. LED will turn on to show the command was received. --- .../lib/systemd/system/button.service | 6 +++--- .../out/rootfs_uclibc_rv1106/usr/local/bin/button.sh | 8 ++++++++ .../usr/local/bin/buttonservice.sh | 10 ---------- 3 files changed, 11 insertions(+), 13 deletions(-) create mode 100644 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/button.sh delete mode 100755 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/buttonservice.sh diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/lib/systemd/system/button.service b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/lib/systemd/system/button.service index 4f91a0c..c285e3d 100644 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/lib/systemd/system/button.service +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/lib/systemd/system/button.service @@ -1,11 +1,11 @@ [Unit] -Description=Button Reboot Service +Description=Button Service After=multi-user.target [Service] -ExecStart=/usr/local/bin/buttonservice.sh +ExecStart=/usr/local/bin/button.sh Restart=always -User=femto +User=root [Install] WantedBy=multi-user.target diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/button.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/button.sh new file mode 100644 index 0000000..efb817b --- /dev/null +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/button.sh @@ -0,0 +1,8 @@ + fi + else + echo "$duration second button press detected. Rebooting." + echo 1 > /sys/class/gpio/gpio34/value; + sudo reboot + fi + fi +done diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/buttonservice.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/buttonservice.sh deleted file mode 100755 index d0d5d81..0000000 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/buttonservice.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -logger "$(date): Listening for button press on $DEVICE..." - -evtest --grab /dev/input/event0 | while read line; do - if echo $line | grep -q "EV_KEY.*value 1"; then - logger "Button pressed, triggering reboot..." - sudo reboot - fi -done