pimoroni / clean-shutdown

Python daemon to watch a GPIO pin and trigger a clean shutdown.
MIT License
125 stars 40 forks source link

Play Sound before Shutdown #17

Closed marcOSS040 closed 1 year ago

marcOSS040 commented 5 years ago

Is it possible to play a sound when the script is triggered to shut down the pi?

Gadgetoid commented 5 years 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.