Run script on boot when Volumio is ready

I’d like to have a custom script (that changes an LED behavior) when Volumio is ready.
There are 2 ways to do so:

  1. a script call when Volumio startup sound plays
  2. a systemd service (managed by OS)

With option (1) I’ll be sure that the script runs when Volumio is actually up and running. But I probably need to tweak Volumio code. First, I don’t know where to look; second, I (probably) need to re-apply the tweak on every update.

Option (2) is easier to implement and cleaner. To have it almost synced with Volumio “ready status” I need to set an “after volumio” directive in the systemd script. It will probably start a little early (not when Volumio is ready ready), but for a simple status LED it will probably be good enough (I’ll do some test in a couple of days).
I’ll also use this approach to change the LED behavior on poweroff/reboot.

What are your thoughts? What’s the best way to have a script run when Volumio is ready? Further/better ways to do so?

I would suggest option2, never mess around with the Volumio code itself.

Try as a service

After=volumio.service mpd.service

Good idea adding mpd to the list.

I finally closed the hardware. :sweat:
So it’s time to start playing with the software!

I tested a systemd script with the flags you suggested, but the LED blinking changes way too early (10 seconds) with respect to Volumio startup sound, so way before Volumio is actually ready.
Any idea about further services to add to the list to better sync with Volumio ready state? Or some check to add to the script run by systemd to configrm that VOlumio is up and running? (check some lock/log file existence, read some status file, …)
A dirrrrty trick can be to add a “sleep” to the script run by systemd; I’ll leave this as a last resort.

I’ve edited my boot script this way


# Wait until Volumio prints "BOOT COMPLETED" on log
# See: volumio3-backend/app/index.js
while [ $bootTerminated -eq 0 ]
  logFilter=`sudo journalctl -t volumio | grep "BOOT COMPLETED"`
  if [ -z "$logFilter"]
    sleep 1
# Run boot ready executable
/home/volumio/scripts/dimmer 20
exit 0

This way my custom software will be run when Volumio is fully up (all plugins loaded) and the startup sound is played (max 1 second delay).