From 2650f062b5778571a1592de33b05f78198cec068 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 4 Jul 2026 08:57:36 +0200 Subject: [PATCH] fix(wireplumber): apply source-muted for Audio/Source modules For a module configured node-type "Audio/Source", node_id_ and source_node_id_ resolve to the same source node, so its primary mute state is stored in muted_. update() unconditionally mapped muted_ to the muted/sink-muted classes and source-muted only to the secondary source_muted_ flag, so a source module could never receive source-muted -- only the sink classes. Gate the mute-class selection on the configured node-type: a source-type module drives source-muted from its primary mute state, while a sink-type module keeps muted/sink-muted for its sink and source-muted for the secondary default source it tracks for {format_source}. The primary node still feeds {volume} via updateVolume, so source-widget volume rendering is unaffected. Fixes #4523. --- src/modules/wireplumber.cpp | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/modules/wireplumber.cpp b/src/modules/wireplumber.cpp index 74563c5d..b3167381 100644 --- a/src/modules/wireplumber.cpp +++ b/src/modules/wireplumber.cpp @@ -527,24 +527,39 @@ auto waybar::modules::Wireplumber::update() -> void { label_.get_style_context()->remove_class("bluetooth"); } - // Handle sink mute state + // A module configured with node-type "Audio/Source" tracks a source as its primary node, so its + // primary mute state (muted_) must drive the source-muted class rather than the sink classes. + const bool is_source_type = g_strcmp0(type_, "Audio/Source") == 0; + + // Handle primary node mute state if (muted_) { // Check muted bluetooth format exists, otherwise fall back to default muted format. if (format_name != "format" && !config_[format_name + "-muted"].isString()) format_name = "format"; format_name += "-muted"; - label_.get_style_context()->add_class("muted"); - label_.get_style_context()->add_class("sink-muted"); + if (is_source_type) { + label_.get_style_context()->add_class("source-muted"); + } else { + label_.get_style_context()->add_class("muted"); + label_.get_style_context()->add_class("sink-muted"); + } } else { - label_.get_style_context()->remove_class("muted"); - label_.get_style_context()->remove_class("sink-muted"); + if (is_source_type) { + label_.get_style_context()->remove_class("source-muted"); + } else { + label_.get_style_context()->remove_class("muted"); + label_.get_style_context()->remove_class("sink-muted"); + } } - // Handle source mute state - if (source_muted_) { - label_.get_style_context()->add_class("source-muted"); - } else { - label_.get_style_context()->remove_class("source-muted"); + // Handle the secondary source mute state (only relevant for sink modules, which additionally + // track the default source for {format_source}). A source module already owns source-muted above. + if (!is_source_type) { + if (source_muted_) { + label_.get_style_context()->add_class("source-muted"); + } else { + label_.get_style_context()->remove_class("source-muted"); + } } // mixer-api is configured with the linear scale, so volume_ holds the raw linear gain. The