diff --git a/src-tauri/src/application_watcher.rs b/src-tauri/src/application_watcher.rs index fd1c6604..7b8007a6 100644 --- a/src-tauri/src/application_watcher.rs +++ b/src-tauri/src/application_watcher.rs @@ -40,24 +40,26 @@ pub fn init_application_watcher() { }; if app_name != previous { - let application_profiles = &APPLICATION_PROFILES.read().await.value; - let application = application_profiles.get(&app_name); - let default = application_profiles.get("opendeck_default"); - for value in crate::shared::DEVICES.iter() { - let device = value.key(); - let Some(profile) = application.and_then(|d| d.get(device)).or(default.and_then(|d| d.get(device))) else { - continue; - }; - if crate::store::profiles::DEVICE_STORES.write().await.get_selected_profile(device).ok().as_ref() == Some(profile) { - continue; + if crate::store::get_settings().value.autoswitch { + let application_profiles = &APPLICATION_PROFILES.read().await.value; + let application = application_profiles.get(&app_name); + let default = application_profiles.get("opendeck_default"); + for value in crate::shared::DEVICES.iter() { + let device = value.key(); + let Some(profile) = application.and_then(|d| d.get(device)).or(default.and_then(|d| d.get(device))) else { + continue; + }; + if crate::store::profiles::DEVICE_STORES.write().await.get_selected_profile(device).ok().as_ref() == Some(profile) { + continue; + } + let _ = app_handle.get_webview_window("main").unwrap().emit( + "switch_profile", + SwitchProfileEvent { + device: device.clone(), + profile: profile.clone(), + }, + ); } - let _ = app_handle.get_webview_window("main").unwrap().emit( - "switch_profile", - SwitchProfileEvent { - device: device.clone(), - profile: profile.clone(), - }, - ); } previous = app_name; } diff --git a/src-tauri/src/store/mod.rs b/src-tauri/src/store/mod.rs index d0109b06..fc693fc5 100644 --- a/src-tauri/src/store/mod.rs +++ b/src-tauri/src/store/mod.rs @@ -140,6 +140,7 @@ pub struct Settings { pub separatewine: bool, pub developer: bool, pub disableelgato: bool, + pub autoswitch: bool, } impl Default for Settings { @@ -159,6 +160,7 @@ impl Default for Settings { separatewine: false, developer: false, disableelgato: false, + autoswitch: true, } } } diff --git a/src/components/SettingsView.svelte b/src/components/SettingsView.svelte index 04310cd2..9adc3a9d 100644 --- a/src/components/SettingsView.svelte +++ b/src/components/SettingsView.svelte @@ -114,6 +114,12 @@ +