Closed sownteedev closed 7 months ago
Thanks for the report. Your problem is, that the on_song_change_hook
isn't only used for sending song change notifications (admittedly a bit counterintuitive). Instead, it fires on a bunch of different events and passes event metadata through via environment variables. So in your case, you should probably do a [ "$PLAYER_EVENT" == "changed" ]
. But you can find an unfortunately not very readable list of available envvars here or just play around with env
in your hook script yourself.
i can't get it. Can u explain ?
U mean, it cant solve ?
No, what I meant is:
To fix your problem, you can just do:
#!/usr/bin/env bash
[ "$PLAYER_EVENT" = "change" ] || [ "$PLAYER_EVENT" = "start" ] || exit 0
songimage=$(playerctl metadata --format "{{ mpris:artUrl }}")
songname=$(playerctl metadata --format "{{ title }}")
song=$(playerctl metadata --format "Artist: {{ artist }}\nAlbum: {{ album }}")
wget -O /tmp/songimage.png $songimage
notify-send -i /tmp/songimage.png "$songname" "$song"
rm /tmp/songimage.png
Oh no, it dont notify anything.
Oh, sorry, should've tested the script before posting it. I edited the message and now it should be working correctly.
I also noticed that there are messages like:
Running "/tmp/tmp.jq4v1DtCuW/notify.sh" using "/usr/bin/fish" with environment variables {"OLD_TRACK_ID": "5viFjDGTnrApmUY5c8qkfw", "PLAYER_EVENT": "change", "TRACK_ID": "61HVbcNeRACZpyvHrc3AnD"}
So you check, how your hook script is being executed.
oh cool, thanks for support <3
Description Notified Dunst but it repeated 3 times when opening a song or there was a new song
Expected behavior I want it just notify 1 time
Compilation flags
Versions (please complete the following information):
This is demo video
https://github.com/Spotifyd/spotifyd/assets/90148193/74ee1b40-0470-4f74-ac5f-a0f6d5ed65c9
This script for spotifyd
This is script for notify with Dunst