-
Notifications
You must be signed in to change notification settings - Fork 459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MPRIS Device Name #1100
MPRIS Device Name #1100
Conversation
Hi and thanks for the contribution! While your approach certainly works, I think that it'd be much nicer, if this setting either were the default or customizable at runtime via some configuration option. The reason for this is that most people probably download a prebuilt Happy to hear your thoughts on that! |
A configuration option sounds like a good idea, I'll give that a try. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good to me now, thanks! You'll need to run cargo fmt
before this is ready, to keep coding style consistent.
In the docs, there's also the sample config, where this new option should be added as well, accompanied by some short explanation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last comment. Apart from that, I think this is ready. Thank you! Now, we'll just have to wait for the maintainers.
The spec says that apps that allow multiple instances should follow this convention. So if the name is "spotifyd" the bus name should be:
Where |
Really the easiest way is just to follow the spec and make the bus name |
Thanks for chiming in! This is indeed something that should be considered.
If the
I can imagine that some use cases might benefit from the explicit naming with |
I'm not sure either? If it's just for the sake of uniqueness purely to allow for multiple instances I would follow the specs suggestion, and really that could just be the default behavior all of the time. On the other hand if it's to let a user know what the instance is in any sort of UI you'd want to set the Identity prop to something like |
Reading the spec, it actually only says that it must have a dot and a unique identifier appended to it's bus name, the As far as ASCII sanitization goes I definitely forgot about that one, I'll make these changes and push it up. |
Do you need it to be the device name for any reason in particular? If it's just for the sake of having a unique name I strongly suggest using what the example suggests as it is the convention that all other players follow. It's also useful to clients because if it's the pid it can be used for other things. |
I suppose either is useful but I've been debugging something that uses this feature and I've been running into issues with Spotifyd's PID not being the same as the one it has on creation when I try to kill it's process, so at the moment it seems like it's not going to be as easy to make use of. |
Pids don't change over the course of a program's life. You're prob getting a pid of a child process/thread of Spotifyd mixed up with the main process/thread. |
Not to mention that 2 equally valid device names could be sanitized into the same name thus breaking the uniqueness guarantee. |
Exactly, the parent process is dying and leaving several child processes. |
Alright, I'll change it to the PID. |
My guess would be that you want the pid of the Tokio runtime. |
If you try to grab a pid before you're in the runtime it may be wrong? |
I sprinkled some My guess is that if you're using systemd (or some other way to daemonize Spotifyd) is that you're not getting the actual PID but the PID of the task that spawns Spotifyd? |
This whole PR could be as simple as: let busname = format!(
"org.mpris.MediaPlayer2.spotifyd.instance{}",
std::process::id()
);
conn.request_name(&busname, true, true, true)
.await
.expect("Failed to register dbus player name"); |
064cf7b
to
5270c3a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need all the b = stuff, you've only got one value and format args can be positional. The only reason to assign them is if it needs to be repeated in the string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for your work!
Revert "Merge pull request Spotifyd#1100 from klay2000/mpris_device_name" This reverts commit e523711, reversing changes made to a4316df.
Added a compilation option to append device names to the end of dbus paths, this allows multiple Spotifyd daemons to be running each with a unique dbus object for MPRIS as long as they have unique device names.