Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions src-tauri/src/application_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions src-tauri/src/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ pub struct Settings {
pub separatewine: bool,
pub developer: bool,
pub disableelgato: bool,
pub autoswitch: bool,
}

impl Default for Settings {
Expand All @@ -159,6 +160,7 @@ impl Default for Settings {
separatewine: false,
developer: false,
disableelgato: false,
autoswitch: true,
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/components/SettingsView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@
<input type="range" min="0" max="270" step="90" bind:value={$settings.rotation} id="settings-rotation" />
</div>

<div class="flex flex-row items-center m-2 space-x-2">
<label for="settings-autoswitch" class="text-neutral-400">{$t("settings.autoswitch")}</label>
<input type="checkbox" bind:checked={$settings.autoswitch} id="settings-autoswitch" />
<Tooltip>{$t("settings.autoswitch.tooltip")}</Tooltip>
</div>

<div class="flex flex-row items-center m-2 space-x-2">
<label for="settings-background" class="text-neutral-400">{$t("settings.background")}</label>
<input type="checkbox" bind:checked={$settings.background} id="settings-background" />
Expand Down
1 change: 1 addition & 0 deletions src/lib/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type Settings = {
separatewine: boolean;
developer: boolean;
disableelgato: boolean;
autoswitch: boolean;
};

import { invoke } from "@tauri-apps/api/core";
Expand Down
2 changes: 2 additions & 0 deletions translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@
"settings.autolaunch": "Beim Anmelden starten:",
"settings.autolaunch.tooltip.1": "Wenn diese Option aktiviert ist, wird {{PRODUCT_NAME}} automatisch beim Anmelden gestartet.",
"settings.autolaunch.tooltip.2": "Wenn du {{PRODUCT_NAME}} mit Flatpak installiert hast, funktioniert diese Option möglicherweise nicht wie vorgesehen",
"settings.autoswitch": "Profil-Autoumschaltung aktivieren:",
"settings.autoswitch.tooltip": "Wenn diese Option aktiviert ist, wechselt das aktive Profil automatisch basierend auf der aktuell fokussierten Anwendung.",
"settings.background": "Im Hintergrund weiterlaufen lassen:",
"settings.background.tooltip": "Wenn diese Option aktiviert ist, wird {{PRODUCT_NAME}} in das System-Tray minimiert und im Hintergrund ausgeführt.",
"settings.backup_config.button": "Konfiguration sichern",
Expand Down
2 changes: 2 additions & 0 deletions translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@
"settings.autolaunch": "Start at login:",
"settings.autolaunch.tooltip.1": "If this option is enabled, {{PRODUCT_NAME}} will automatically start at login.",
"settings.autolaunch.tooltip.2": "If you used Flatpak to install {{PRODUCT_NAME}}, this option may not function as intended.",
"settings.autoswitch": "Enable profile auto switching:",
"settings.autoswitch.tooltip": "If this option is enabled, the active profile will switch automatically based on the currently focussed application.",
"settings.background": "Run in background:",
"settings.background.tooltip": "If this option is enabled, {{PRODUCT_NAME}} will minimise to the tray and run in the background.",
"settings.backup_config.button": "Back up config",
Expand Down