Browse Source

Do not crash when no audio sink device is available

The volume block would cause the main thread to panic when no default
sink device was available. This typically happens during login when
pulseaudio or wireplumber has not fully started yet.

Return an empty string for the volume block instead of crashing.
Frans Bergman 11 months ago
parent
commit
42ba53ea71
1 changed files with 2 additions and 4 deletions
  1. 2 4
      src/block/volume.rs

+ 2 - 4
src/block/volume.rs

@@ -11,9 +11,7 @@ impl Block for Volume {
 
 
         handler
         handler
             .get_default_device()
             .get_default_device()
-            .expect("No device")
-            .volume
-            .min()
-            .to_string()
+            .map(|device| device.volume.min().to_string())
+            .unwrap_or_default()
     }
     }
 }
 }