fix: remove redundant volume_state=None, improve pactl volume parser for stereo sinks
This commit is contained in:
@@ -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