fix: remove redundant volume_state=None, improve pactl volume parser for stereo sinks
This commit is contained in:
@@ -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;
|
||||
});
|
||||
}
|
||||
@@ -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")]
|
||||
|
||||
Reference in New Issue
Block a user