fix: wireplumber module when used with a bluetooth device
This fixes #1811 by falling back to `node.description` if `node.nick` is not available. This can happen for bluetooth devices that do not have a `node.nick`.
This commit is contained in:
parent
cea59ddc6c
commit
60fa5e9f67
|
@ -54,17 +54,25 @@ uint32_t waybar::modules::Wireplumber::getDefaultNodeId(waybar::modules::Wireplu
|
||||||
}
|
}
|
||||||
|
|
||||||
void waybar::modules::Wireplumber::updateNodeName(waybar::modules::Wireplumber* self) {
|
void waybar::modules::Wireplumber::updateNodeName(waybar::modules::Wireplumber* self) {
|
||||||
auto proxy = static_cast<WpPipewireObject*>(wp_object_manager_lookup(
|
auto proxy = static_cast<WpProxy*>(
|
||||||
self->om_, WP_TYPE_GLOBAL_PROXY, WP_CONSTRAINT_TYPE_PW_GLOBAL_PROPERTY, "object.id", "=u",
|
wp_object_manager_lookup(self->om_, WP_TYPE_GLOBAL_PROXY, WP_CONSTRAINT_TYPE_G_PROPERTY,
|
||||||
self->node_id_, NULL));
|
"bound-id", "=u", self->node_id_, NULL));
|
||||||
|
|
||||||
if (!proxy) {
|
if (!proxy) {
|
||||||
throw std::runtime_error(fmt::format("Object '{}' not found\n", self->node_id_));
|
throw std::runtime_error(fmt::format("Object '{}' not found\n", self->node_id_));
|
||||||
}
|
}
|
||||||
|
|
||||||
g_autoptr(WpProperties) properties = wp_pipewire_object_get_properties(proxy);
|
g_autoptr(WpProperties) properties =
|
||||||
|
WP_IS_PIPEWIRE_OBJECT(proxy) ? wp_pipewire_object_get_properties(WP_PIPEWIRE_OBJECT(proxy))
|
||||||
|
: wp_properties_new_empty();
|
||||||
|
g_autoptr(WpProperties) global_p = wp_global_proxy_get_global_properties(WP_GLOBAL_PROXY(proxy));
|
||||||
properties = wp_properties_ensure_unique_owner(properties);
|
properties = wp_properties_ensure_unique_owner(properties);
|
||||||
self->node_name_ = wp_properties_get(properties, "node.nick");
|
wp_properties_add(properties, global_p);
|
||||||
|
wp_properties_set(properties, "object.id", NULL);
|
||||||
|
auto nick = wp_properties_get(properties, "node.nick");
|
||||||
|
auto description = wp_properties_get(properties, "node.description");
|
||||||
|
|
||||||
|
self->node_name_ = nick ? nick : description;
|
||||||
}
|
}
|
||||||
|
|
||||||
void waybar::modules::Wireplumber::updateVolume(waybar::modules::Wireplumber* self) {
|
void waybar::modules::Wireplumber::updateVolume(waybar::modules::Wireplumber* self) {
|
||||||
|
@ -120,6 +128,7 @@ void waybar::modules::Wireplumber::activatePlugins() {
|
||||||
|
|
||||||
void waybar::modules::Wireplumber::prepare() {
|
void waybar::modules::Wireplumber::prepare() {
|
||||||
wp_object_manager_add_interest(om_, WP_TYPE_NODE, NULL);
|
wp_object_manager_add_interest(om_, WP_TYPE_NODE, NULL);
|
||||||
|
wp_object_manager_add_interest(om_, WP_TYPE_GLOBAL_PROXY, NULL);
|
||||||
wp_object_manager_request_object_features(om_, WP_TYPE_GLOBAL_PROXY,
|
wp_object_manager_request_object_features(om_, WP_TYPE_GLOBAL_PROXY,
|
||||||
WP_PIPEWIRE_OBJECT_FEATURES_MINIMAL);
|
WP_PIPEWIRE_OBJECT_FEATURES_MINIMAL);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue