Closed marcOSS040 closed 1 year ago
This is supported natively by Linux (systemd) so you can just drop a script into /lib/systemd/system-shutdown/
and it will be run before shutdown/reboot. See: https://www.freedesktop.org/software/systemd/man/systemd-halt.service.html
If your script looks at the one argument its passed you can also check for halt
, poweroff
or reboot
to see what's actually happening and react accordingly.
Is it possible to play a sound when the script is triggered to shut down the pi?