[PATCH swayrbar] Don't crash on empty wpctl output
Export this patch
---
swayrbar/src/module/wpctl.rs | 10 ++++++ ----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/swayrbar/src/module/wpctl.rs b/swayrbar/src/module/wpctl.rs
index be9f4f4..b51b268 100644
--- a/swayrbar/src/module/wpctl.rs
+++ b/swayrbar/src/module/wpctl.rs
@@ -52,10 +52,12 @@ fn run_wpctl(args: &[&str]) -> String {
fn get_volume(device: &str) -> (u8, bool) {
let output = run_wpctl(&["get-volume", device]);
let mut volume = String::new();
- VOLUME_RX
- .captures(&output)
- .unwrap()
- .expand("$num$frac", &mut volume);
+ if !output.is_empty() {
+ VOLUME_RX
+ .captures(&output)
+ .unwrap()
+ .expand("$num$frac", &mut volume);
+ }
(volume.parse::<u8>().unwrap_or(255_u8), output.contains("[MUTED]"))
}
--
2.46.2
bitraid <bitraid@protonmail.ch> writes:
Applied, thanks! Just for me to know how serious that issue is: under
what conditions does wpctl give empty output?
Bye,
Tassilo