fix: remove redundant volume_state=None, improve pactl volume parser for stereo sinks

This commit is contained in:
Asger Geel Weirsøe
2026-05-06 09:53:27 +02:00
parent 74e0f544a0
commit 355828d4d9
2 changed files with 10 additions and 4 deletions

View File

@@ -142,6 +142,5 @@ pub unsafe extern "C" fn g_module_unload(_module: *mut c_void) {
state.animation = None;
state.audio_uri = None;
state.config.deadzone = None;
state.volume_state = None;
});
}

View File

@@ -69,9 +69,16 @@ fn get_current_volume() -> (u32, bool) {
#[cfg(target_os = "linux")]
fn parse_pactl_volume(output: &str) -> Option<u32> {
output.split('%').next()
.and_then(|s| s.split_whitespace().last())
.and_then(|s| s.parse().ok())
for token in output.split_whitespace() {
if let Some(pct) = token.strip_suffix('%') {
if let Ok(v) = pct.parse::<u32>() {
if v <= 100 {
return Some(v);
}
}
}
}
None
}
#[cfg(target_os = "linux")]