Hi everyone, balenaSound maintainer here
Just want to add to what my colleague explained above. balenaSound 2.x versions actually have some sort of support for this use case in the form of “bluetooth scripts”.
Basically balenaSound allows you to run user-provided scripts on connect/disconnect bluetooth events. You can read on how to enable this here and we have sample scripts that toggle GPIO pins here. This is ofc limited to bluetooth playback (spotify/airplay/upnp won’t work with this feature).
A quick notice on this feature though. balenaSound v2.4.10 is the last version where this will be available. I’m planning on releasing balenaSound v3.0 tomorrow hopefully and this feature will not be implemented in there. An upcoming update to 3.x will include the ability to run this type of scripts regardless of the audio source that’s currently streaming, but that won’t be ready for 3.0. I created a GH issue to track progress on this: https://github.com/balenalabs/balena-sound/issues/282
Finally, my last advise is to be extra safe and careful when working with this types of projects. Be sure to read on and test stuff properly before actually putting everything together to avoid potentially damaging expensive audio equipment!