Spotifyd / spotifyd

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

Spotifyd doesn't start automatically with DBus support enabled. #895

Closed NNEU-1 closed 3 years ago

NNEU-1 commented 3 years ago

Description Hi, I've got a little issue with Spotifyd. I used to run it in the default configuration without an extra compilation flags. It was set up to show as the machine name in the .service file ExecStart=/usr/bin/spotifyd --no-daemon --device-name "%H"

after enabling DBus support by recompiling with the according flags and settings in the .conf file, the device will still show in Spotify, but no longer be able to connect.

if I start Spotifyd by typing it into the command prompt, a second device shows up in Spotify as "Spotifyd@{HOSTNAME}". I can connect to that device and use the DBus successfully.

Any ideas what causes this issue and how it can be fixed ?

Thanks !

Compilation flags

Versions (please complete the following information):

robinvd commented 3 years ago

What is the device name? Sometimes spaces or other special characters mess things up

NNEU-1 commented 3 years ago

That’s not the issue. The host name only contains upper case letters and no special characters or spaces. Also, that wouldn’t explain the difference between the behavior with or without the DBus option enabled.

NNEU-1 commented 3 years ago

I have observed the issue more in-depth, and perhaps my original description of the problem is a bit misleading.

The following configuration:

exhibits the following behaviour:

then, if I start Spotifyd in the terminal, it will launch as another device.

So perhaps this is not a "doesn't autostart" issue, but a "doesn't connect" one. Strangely though, it does seem to be related to the addition of the DBus option.

NNEU-1 commented 3 years ago

Hello again, I tried to install Spotifyd on Ubuntu to see if the problem also occurs there as well.

Again, installed with the DBus_mpris feature.

The problem is similar to what I experienced earlier on the yocto machine.

Spotifyd autostarts and appears as connect client. However, there is no music playback and no possibility to interact with DBus.

Error org.freedesktop.DBus.Error.ServiceUnknown: The name org.mpris.MediaPlayer2.spotifyd was not provided by any .service files Then again, as in yocto, if I start Spotifyd in the terminal, I can see a second connect client which is fully functional with DBus and playback.

I hope this makes it easier to reproduce and hopefully get some suggestions. Thanks !

NNEU-1 commented 3 years ago

I have now discovered that the issue is fixed by running spotifyd as a user service. However, I would prefer it to run as a system service so that no login is required for the service to start.

Again, any kind of feedback would be highly appreciated.

robinvd commented 3 years ago

as what user is the system service started? and can you try starting it from that user

NNEU-1 commented 3 years ago

originally I had no user specified in the .service file. It was just like the one offered here on Github, with the addition of the hostname attribute.

I also tried adding "User=root", with no success.

It only worked once I made it a user service (user is root). I removed the audio and network targets and moved the service to /usr/lib/systemd/user/ (instead of /lib/systemd/system/)

stale[bot] commented 3 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.

mativ123 commented 1 year ago

Dbus gives the error message because spotifyds dbus service name isn't just "org.mpris.MediaPlayer2.spotifyd". It has the instance number on the end. E.g. the name of the spotifyd dbus service on my pc was "org.mpris.MediaPlayer2.spotifyd.instance2176".

To find yours select spotifyd as current device in the spotify app and run the command: dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListNames

It should then show up in the list of current available D-Bus services.

Beware the instance number changes each time the spotifyd deamon starts