Spotifyd / spotifyd

A spotify daemon
https://spotifyd.rs
GNU General Public License v3.0
9.79k stars 447 forks source link

Check if spotifyd is playing #996

Closed rolodato closed 2 years ago

rolodato commented 3 years ago

I'm using spotifyd with a Raspberry Pi connected to a TV, and it works great! If spotifyd is not playing anything for a while, I would like to turn the TV off via HDMI CEC only if the Pi's HDMI input is still active (this avoids turning the TV off if I'm using a different input or app on the TV).

I've mostly managed to do this by using on_song_change hooks by scheduling a "TV off" command when playback stops, and canceling the command when playback resumes. However, CEC active input detection is not 100% reliable on my TV and sometimes reports an unknown status, so the "TV off" command will not be scheduled when playback stops. To handle this case, I would like to periodically (every ~5 mins) query spotifyd to determine if it's playing, retry the active input check and turn the TV off if it's inactive.

Looking through old issues I've found mentions of a CUR_PLAYING status but I think that's been since removed. Is there any way to achieve this with spotifyd, or could it be added? Thanks!

Icelk commented 2 years ago

Using playerctl (or spotify-tui for that part) you can get the status of the programs playing audio. The playerctl metadata command can get the metadata of spotifyd, if you are connected to the internet.

You can also use pactl to get the clients. Spotifyd will only appear if it's playing. This command will return an error status code if no spotifyd is playing.

$ pactl list clients | grep -i spotifyd
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.