rpi_poweroff_button.service 1.58 KB
#
# rpi_poweroff_button.service – Systemd service to implement a poweroff button
#
# Version 1.0, latest version, documentation and bugtracker available at:
#		https://gitlab.lindenaar.net/scripts/raspberrypi
#
# Copyright (c) 2019 Frederik Lindenaar
#
# This script is free software: you can redistribute and/or modify it under the
# terms of version 3 of the GNU General Public License as published by the Free
# Software Foundation, or (at your option) any later version of the license.
#
# This script is distributed in the hope that it will be useful but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program.  If not, visit <http://www.gnu.org/licenses/> to download it.
#

# Please note this requires gpio_trigger.py installed in /usr/local/sbin, see:
# https://frederik.lindenaar.nl/2019/10/23/raspberry-pi-power-off-button.html

# To install copy to /etc/systemd/system/rpi_poweroff_button.service
# enable it to start during boot with:  systemctl enable rpi_poweroff_button
# temporarily enable with:              service rpi_poweroff_button start
# temporarily disable with:             service rpi_poweroff_button stop
# disable starting during boot with:    systemctl disable rpi_poweroff_button

[Unit]
Description=Power-off button on GPIO

[Service]
Type=idle
ExecStart=/usr/local/sbin/gpio_trigger.py --hold 5000 poweroff
Restart=always
RestartSec=30

[Install]
WantedBy=default.target