This thread contains a patchset. You're looking at the original emails,
but you may wish to use the patch review UI.
Review patch
3
2
[PATCH swayrbar] Don't crash on empty wpctl output
---
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
> ---
> 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]"))
> }
I've only seen this on system startup, where the server isn't ready yet. There is a message on stderr, and stdout is empty.
On Saturday, October 5th, 2024 at 10:27, Tassilo Horn <tsdh@gnu.org > wrote:
> 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
>
> > ---
> > 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]"))
> > }
bitraid <bitraid@protonmail.ch > writes:
> I've only seen this on system startup, where the server isn't ready
> yet. There is a message on stderr, and stdout is empty.
I've released 0.4.2 just now. Better be safe than sorry.
Thanks,
Tassilo