elenapan / dotfiles

There is no place like ~/
GNU General Public License v2.0
3.51k stars 175 forks source link

Spotify Info/Controls Sidebar #120

Closed EllatharTheHalfling closed 4 years ago

EllatharTheHalfling commented 4 years ago

Hello First can I say how much I love your work? Ephemeral is what drew me in and I spent a good 2-ish months just discovering, tweaking, sometimes outright removing functions that I just didn't need and replacing them with others. But something that I tried to do, that had stumped me for a bit, was spotify info and controls in the sidebar. Eventually I gave up on that and simply mapped my media keys to access spotify exclusively and if I wanted to know a song I would break from my routine to go to its tab to view the info.

Now I see that you have spotify sitting in noodle and evil, this gave me hope and so I updated. Re-tweaking is going by much faster. Run into a few issues here and there, but nothing too major. But Spotify..I'm hitting the same wall I did back with the old setup. I see the options, based on the files it should be possible. Just can't figure out how.

So that's really what I'm asking for at this point. Any guidance on how to get spotify info up on the sidebar and use the media controls there to control spotify would be appreciated.

ceuk commented 4 years ago

IIRC you can just replace the current media widget in the sidebar, e.g. https://www.github.com/ceuk/dotfiles/tree/laptop/config%2Fawesome%2Fnoodle%2Fsidebar.lua

Also, see #49

EllatharTheHalfling commented 4 years ago

Oh, actually that helped a bunch. Thanks for that. Thought it does prove that I was looking at it in a more complicated way. first off, i didn't have playerctl installed at all, so that was a problem. Before checking back here I decided to modify the mpd_buttons.lua file and replace the next/toggle/previous buttons with the dbus media controls for spotify using mpris. while that had given me the controls, it didn't provide anything else and the solution on that route started to get seriously complicated.

So anyway, thank you for your help. Next is PAM, Picom and figuring out if there's a way to change the week format on the sidebar. (start sunday instead of start monday. can obviously change initials, but nothing beyond that yet. if you have any clues to this that can point me in the right direction that'd be cool, too. however it's not really an issue)

elenapan commented 4 years ago

@EllatharTheHalfling Regarding changing the week format in the sidebar (and your other questions), you can always open a new issue and I will be happy to help.

taylor85345 commented 4 years ago

I'm trying to accomplish the same task of having spotify (or any other playerctl-compatible player) show in the media widget. I've updated my elemental/sidebar/amarena.lua to use noodle.spotify instead of noodle.mpd_song:

local mpd_song = require ("noodle.spotify")

but I only get the hard-coded "---" text returned in the widget instead of the track information. I have tested with spotifyd, and confirmed that playerctl is properly controlling spotifyd and outputting the appropriate metadata. I've also tinkered around in both noodle/spotify.lua and evil/spotify.lua, and even tried replacing those files with the equivalents from @ceuk. Any ideas what I might be missing?

Also, sorry for re-opening a closed issue. :)

EllatharTheHalfling commented 4 years ago

Just to note, this might be because of spotifyd running as a daemon, rather than a stand alone player and you might have an easier time plugging that into ncmpcpp via mopidy.

I know when i finally had gotten it to work after installing playerctl the system wouldn't read the spotify data until I had started it using the sidebar.

I'll look into it on my end as I have been playing around with it since and this is another project that would be fun, but hopefully someone else can chime in with other suggestions.

elenapan commented 4 years ago

@taylor85345 Does running the following command in the terminal produce any output whenever the pausing/unpausing or skipping a song? It is a variation of the command used by evil/spotify.lua to grab the current song information.

playerctl metadata --format '{{artist}} - {{title}} [[Status: {{status}}]]' --follow

P.S.: I have now realized that multiple players might show up in that output in addition to Spotify (e.g. a video playing in a Firefox tab). I will push a fix soon-ish (as soon as I reinstall Spotify for testing this) so that only Spotify info is printed.

taylor85345 commented 4 years ago

Thanks for the suggestions!

@EllatharTheHalfling I tried killing the spotifyd service and running it manually from the sidebar, and the result was the same. No track output in the widget. I may try mopidy as a last resort, but I'm actually more interested in playerctl control than specifically Spotify, as playerctl also works with Plex Media Player and Plexamp.

@elenapan I'd tested playerctl for metadata output already and that all looks good. The output of the command you provided was as follows:

Sturgill Simpson - I Don't Mind [[Status: Playing]]

I do notice that spotifyd does not automatically update playerctl with the current track info when using "--follow" the way that other players do, but that doesn't seem to be directly related the issue here as I have confirmed the same result with the official Spotify client and several other players that do automatically update playerctl when using "--follow".

Also feel free to take your time making the widget Spotify exclusive! Generic playerctl support is actually what I'm going for here, and the Spotify widget just seems to fit the bill.

taylor85345 commented 4 years ago

On a side note, if evil/spotify.lua is supposed to be running as a daemon, I think I should expect to see the "sh -c playerctl ..." script running continually in top/htop as a background process, but it is not. Am I wrong about this? Is it possible that the evil/spotify daemon is not initializing properly on my system?

elenapan commented 4 years ago

I do notice that spotifyd does not automatically update playerctl with the current track info when using "--follow" the way that other players do...

I will have to look into this, as it seemed to work this way the last time I tested this.

Is it possible that the evil/spotify daemon is not initializing properly on my system?

Well, now this makes a lot of sense. The evil/spotify.lua file is not loaded by default on my config, as I do not use Spotify. In evil/init.lua you might see that the line which loads this file is commented out, which makes it so that the playerctl script never runs and, as a result, the evil::spotify signal is never fired.

https://github.com/elenapan/dotfiles/blob/caca49e3fa01593690f86f1a0f2ca2051df2e738/config/awesome/evil/init.lua#L8-L13

Uncommenting that line will most probably fix the issue.

taylor85345 commented 4 years ago

That did the trick! I'm getting title and artist output in the widget now. I had a feeling it was something simple like that, but I didn't know which file to look in. I'm still figuring out how all of these files tie in to each other!

taylor85345 commented 4 years ago

Also, new track info in spotifyd definitely isn't updating automatically, but that is probably something to take up with the spotifyd devs.

elenapan commented 4 years ago

Thank you for the update!

This spotifyd issue seems related: https://github.com/Spotifyd/spotifyd/issues/455