I use rockbox on some old Sansa clip devices and it has a brilliant feature explained here where you can automatically enable sleep on boot and restart the countdown every time you press a key.
I wanted this on Volumio, so I wrote a Python client that connects to the socket.io server and enables sleep if it’s not already enabled on every play event. This is triggered when you start playing a track or when it skips to the next track. I used the brilliant mpdcron app to listen for the events as it’s very simple to install and use and seems pretty bulletproof.
I’m sure this could all have been done using curl or something within the mpdcron player hook script, but I’ve got much more experience in Python than bash so this was easier for me!
Rather than post it here directly, I’ve put the code and detailed installation instructions on Githubh here.
I’d love to hear if anyone uses this. I’m more than happy for people to fork my code and modify it if you include references to the original and if anyone wants to turn this into a plugin: brilliant! Go for it! That way upgrades etc won’t affect it hopefully.
I’ve posted this as a suggested feature here, but I’m impatient and implemented my own version.