Skip to content

Commit 0500ca2

Browse files
mokhnatchukbim9262
authored andcommitted
fix(sound): improve headphones detection for PipeWire
PipeWire often reports form_factor as Unknown, causing the headphones icon to miss. This patch adds a fallback check for the active_port name.
1 parent 4755643 commit 0500ca2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/blocks/sound.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,11 @@ pub async fn run(config: &Config, api: &CommonApi) -> Result<()> {
160160
Some("headset") | Some("headphone") | Some("hands-free") | Some("portable") => true,
161161
// Per discussion at
162162
// https://github.com/greshake/i3status-rust/pull/1363#issuecomment-1046095869,
163-
// some sinks may not have the form_factor property, so we should fall back to the
164-
// active_port if that property is not present.
165-
None => active_port.is_some_and(|p| p.to_lowercase().contains("headphones")),
166-
// form_factor is present and is some non-headphone value
167-
_ => false,
163+
// fall back to checking active_port if form_factor is absent, unknown, or doesn't match
164+
// known headphone values (common on PipeWire/WirePlumber systems).
165+
_ => active_port
166+
.as_ref()
167+
.is_some_and(|p| p.to_lowercase().contains("headphone")),
168168
};
169169
if headphones {
170170
return "headphones";

0 commit comments

Comments
 (0)