~tsdh/public-inbox

swayrbar: Don't crash on empty wpctl output v1 PROPOSED

bitraid: 1
 Don't crash on empty wpctl output

 1 files changed, 6 insertions(+), 4 deletions(-)
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.



          
          
          
        
      

      
      
      
      

      
      
        
          






bitraid <bitraid@protonmail.ch> writes:
Next
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~tsdh/public-inbox/patches/55336/mbox | git am -3
Learn more about email & git

[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