mirror of
https://github.com/femtofox/femtofox.git
synced 2026-11-21 07:26:31 -05:00
added button press service
This commit is contained in:
parent
92d112b10e
commit
1dabf61ac2
3 changed files with 29 additions and 0 deletions
11
scripts/button.service
Normal file
11
scripts/button.service
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
[Unit]
|
||||
Description=Button Reboot Service
|
||||
After=multi-user.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/local/bin/buttonservice.sh
|
||||
Restart=always
|
||||
User=femto
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
10
scripts/buttonservice.sh
Normal file
10
scripts/buttonservice.sh
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#!/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
|
||||
|
|
@ -12,6 +12,14 @@ sudo mount -t tmpfs tmpfs /run -o remount,size=32M,nosuid,noexec,relatime,mode=7
|
|||
sudo sh -c 'echo "tmpfs /run tmpfs size=32M,nosuid,noexec,relatime,mode=755 0 0" >> /etc/fstab' #Embiggen tmpfs - for future boots.
|
||||
echo "[1;32m*** $(date "+%H:%M:%S %Z"): Enlarged tmpfs ***\e[0m\n"
|
||||
|
||||
sudo chmod +x buttonservice.sh
|
||||
sudo mv buttonservice.sh /usr/local/bin
|
||||
sudo mv button.service /etc/systemd/system
|
||||
sudo usermod -aG input $USER
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable button.service
|
||||
echo "[1;32m*** $(date "+%H:%M:%S %Z"): Added reboot on BOOT button press ***\e[0m\n"
|
||||
|
||||
sudo timedatectl set-timezone UTC #Set timezone to UTC.
|
||||
date -d "$(wget --method=HEAD -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f4-10)" #Set time/date.
|
||||
echo "[1;32m*** $(date "+%H:%M:%S %Z") Changed timezone to UTC and got network time ***\e[0m\n"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue