Skip to content

Commit 76f5d2e

Browse files
committed
feat(sound): auto-select first available profile if device is Off
1 parent b243d19 commit 76f5d2e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

subscriptions/sound/src/lib.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,23 @@ impl Model {
405405
}
406406

407407
pipewire::Event::ActiveProfile(id, profile) => {
408+
// If the profile was automatically set to Off, auto-select the first available profile.
409+
if self.last_set_profile != Some((id, 0)) && profile.index == 0 {
410+
if let Some(profiles) = self.device_profiles.get(id) {
411+
for profile in profiles {
412+
if profile.index != 0
413+
&& profile.name != "pro-audio"
414+
&& !matches!(profile.available, Availability::No)
415+
{
416+
let index = profile.index as u32;
417+
tokio::spawn(async move {
418+
set_profile(id, index).await;
419+
});
420+
}
421+
}
422+
}
423+
}
424+
408425
let index = profile.index as u32;
409426
self.active_profiles.insert(id, profile);
410427
self.update_ui_profiles();

0 commit comments

Comments
 (0)