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.animation = None;
|
||||||
state.audio_uri = None;
|
state.audio_uri = None;
|
||||||
state.config.deadzone = None;
|
state.config.deadzone = None;
|
||||||
state.volume_state = None;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -69,9 +69,16 @@ fn get_current_volume() -> (u32, bool) {
|
|||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
fn parse_pactl_volume(output: &str) -> Option<u32> {
|
fn parse_pactl_volume(output: &str) -> Option<u32> {
|
||||||
output.split('%').next()
|
for token in output.split_whitespace() {
|
||||||
.and_then(|s| s.split_whitespace().last())
|
if let Some(pct) = token.strip_suffix('%') {
|
||||||
.and_then(|s| s.parse().ok())
|
if let Ok(v) = pct.parse::<u32>() {
|
||||||
|
if v <= 100 {
|
||||||
|
return Some(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
|
|||||||
Reference in New Issue
Block a user