1
0
Fork 0
mirror of https://github.com/librespot-org/librespot.git synced 2025-10-04 02:09:26 +02:00

Use the librespot name arg for the app name in the PulseAudio backend

This sets the name displayed by PulseAudio to Librespot - Instance Name if a name is given otherwise Librespot (the default name).

This also sets the correct "role" as per the docs:

https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/Developer/Clients/ApplicationProperties/

PA_PROP_MEDIA_ROLE

"This is a property of the actual streamed data, not so much the application"

Roles are used for policies, things like automatically muting a music player when a call comes in and whatnot.

For bonus points this also sets PULSE_PROP_application.icon_name to audio-x-generic so that we get a nice icon in the PulseAudio settings by our name instead of a missing icon placeholder.
This commit is contained in:
JasonLG1979 2022-03-07 20:12:18 -06:00
parent 616809b64c
commit e0e23c9167
3 changed files with 62 additions and 19 deletions

View file

@ -1124,6 +1124,43 @@ fn get_setup() -> Setup {
exit(1);
}
#[cfg(feature = "pulseaudio-backend")]
{
if env::var("PULSE_PROP_application.name").is_err() {
let pulseaudio_name = if name != connect_default_config.name {
format!("{} - {}", connect_default_config.name, name)
} else {
name.clone()
};
env::set_var("PULSE_PROP_application.name", pulseaudio_name);
}
if env::var("PULSE_PROP_application.version").is_err() {
env::set_var("PULSE_PROP_application.version", version::SEMVER);
}
if env::var("PULSE_PROP_application.icon_name").is_err() {
env::set_var("PULSE_PROP_application.icon_name", "audio-x-generic");
}
if env::var("PULSE_PROP_application.process.binary").is_err() {
env::set_var("PULSE_PROP_application.process.binary", "librespot");
}
if env::var("PULSE_PROP_stream.description").is_err() {
env::set_var("PULSE_PROP_stream.description", "Spotify Connect endpoint");
}
if env::var("PULSE_PROP_media.software").is_err() {
env::set_var("PULSE_PROP_media.software", "Spotify");
}
if env::var("PULSE_PROP_media.role").is_err() {
env::set_var("PULSE_PROP_media.role", "music");
}
}
let initial_volume = opt_str(INITIAL_VOLUME)
.map(|initial_volume| {
let volume = match initial_volume.parse::<u16>() {