mirror of
https://github.com/Rigellute/spotify-tui.git
synced 2026-04-26 08:05:57 +03:00
[GH-ISSUE #146] Current Playing Notifications #81
Labels
No labels
bug
enhancement
good first issue
help wanted
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/spotify-tui#81
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @SethGower on GitHub (Nov 11, 2019).
Original GitHub issue: https://github.com/Rigellute/spotify-tui/issues/146
A feature I really enjoy in the official Spotify Client, which I would like to see in

sptis the current playing notification. It includes the song title, artist and album art. I have been debating on which service to implement this in, whether it should go insptorspotifyd, and figure the best and most efficient way of implementing it would be insptsince all of the track information is already available, and there is already an API key entangled with the service, allowing for the necessary API calls. If it were implemented inspotifydinstead, then a new API key would need to be generated in order to get the current playing art, info, etc. I am making this issue to solely to have this recorded somewhere, but I plan on implementing this in the nearish future. Also wanted to get any input from other contributors if you all had any other ideas/suggestions. Here is an example of what I am talking about (pardon the Christmas music in November).@Rigellute commented on GitHub (Nov 11, 2019):
Interesting idea - are these operating system notifications?
@SethGower commented on GitHub (Nov 11, 2019):
@Rigellute Yes. I was planning on implementing using
libnotify, as Spotify client does@SethGower commented on GitHub (Nov 12, 2019):
I have finished creating the function to actually send the notification. It looks Almost identical to the notification that spotify serves.

Now that I have it working, I could use some help on figuring out where to actually implement it. If you want to see the code, it is here. I need to find a way to only call the function when the song has changed/when the state has changed. Any suggestions?
@Rigellute commented on GitHub (Nov 13, 2019):
There's currently no elegant way of checking if the song has changed.
Every 5 seconds we poll the spotify API for current playback context. After certain events (like skipping a track) we also attempt to fetch playback context, but there is a race here so the response is not always accurate.
I would put the "has song changed" logic in
get_current_playbackfunction here https://github.com/Rigellute/spotify-tui/blob/master/src/app.rs#L332Check if the local playback context is different from the context we've fetched from the API (use the track id).
This would be something like
self.current_playback_context.item.track.id(although you'd need to handle the Options in this chain).Hope that makes sense?
@SethGower commented on GitHub (Nov 13, 2019):
Ok, that was what I was thinking. I figured I would just mention it, in case I missed it, given I am still becoming familiar with rust. Thanks for all of the help!