Spotifyd / spotifyd

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

on_song_change_hook triggered for multiple PLAYER_EVENTS #1272

Closed teddywaweru closed 7 months ago

teddywaweru commented 8 months ago

I had anticipated that the on_song_change_hook would be triggered for the PLAYER_EVENT "play", but I have had scenarios where it's triggered for the "preload", "preloading", "endoftrack" and "change" events as well. I'd wanted to use the hook to notify the next song specifically, but it seems to be triggered by multiple events.

eladyn commented 8 months ago

Well, you can just filter by the event it is triggered for. So for example in a bash script, you can do:

#!/bin/bash

[ "$PLAYER_EVENT" = "play" ] || exit 0

# rest of script
teddywaweru commented 8 months ago

It's actually what I required. Thanks. Still curious on whether it would be feasible to have the filter within spotifyd itself so that it isn't always triggering for each player_event, and users can specify which events they want to hook to in their spotifyd configs.

eladyn commented 7 months ago

I think that this would make configuration unnecessarily complicated, when all the functionality is already there. Maybe adding documentation to this option would make it easier to use? Something like #1271?

teddywaweru commented 7 months ago

Yeah, that's a better solution than overhauling the config. Also, my limited know-how on exported variables made me unable to figure this out initially. Thank you.