From f7daf743434161aab89ce28522ddf83dca8c8e7e Mon Sep 17 00:00:00 2001 From: TheBiemGamer <47662596+TheBiemGamer@users.noreply.github.com> Date: Mon, 16 Nov 2026 13:33:56 +0000 Subject: [PATCH 1/4] feat: keep the PC awake while a game runs Windows holds SetThreadExecutionState on its own thread; Linux holds the desktop portal's Inhibit (idle and suspend) over zbus, which also works in the Flatpak. The poll takes the hold while a game runs and drops it when the game ends; Guild exiting ends it with its thread or bus connection. --- src-tauri/Cargo.lock | 1 + src-tauri/Cargo.toml | 3 +- src-tauri/src/commands/library.rs | 5 +++ src-tauri/src/commands/mod.rs | 2 + src-tauri/src/msg.rs | 2 + src-tauri/src/platform.rs | 75 +++++++++++++++++++++++++++++++ src/lib/i18n/en.json | 1 + src/lib/i18n/nl.json | 1 + 8 files changed, 89 insertions(+), 1 deletion(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index a64649e..aa376c0 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -2623,6 +2623,7 @@ dependencies = [ "windows-native-keyring-store", "windows-sys 0.61.2", "winreg", + "zbus", "zbus-secret-service-keyring-store", ] diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index de1a117..395742d 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -37,11 +37,12 @@ tracing-subscriber = { version = "0.3", default-features = false, features = ["f [target.'cfg(windows)'.dependencies] windows-native-keyring-store = { version = "1.1", default-features = false } -windows-sys = { version = "0.61", features = ["Win32_Foundation", "Win32_Globalization", "Win32_Security", "Win32_Storage_FileSystem", "Win32_System_Diagnostics_ToolHelp", "Win32_System_JobObjects", "Win32_System_Threading"] } +windows-sys = { version = "0.61", features = ["Win32_Foundation", "Win32_Globalization", "Win32_Security", "Win32_Storage_FileSystem", "Win32_System_Diagnostics_ToolHelp", "Win32_System_JobObjects", "Win32_System_Power", "Win32_System_Threading"] } winreg = "0.56" [target.'cfg(target_os = "linux")'.dependencies] libc = "0.2" +zbus = "5" zbus-secret-service-keyring-store = { version = "1", features = ["rt-async-io-crypto-rust"] } [build-dependencies] diff --git a/src-tauri/src/commands/library.rs b/src-tauri/src/commands/library.rs index 6a3283d..be5f06e 100644 --- a/src-tauri/src/commands/library.rs +++ b/src-tauri/src/commands/library.rs @@ -1351,6 +1351,11 @@ fn poll_blocking(app: &AppHandle) -> Poll { let setup_percent = preparing .filter(|p| running.as_ref() == Some(&p.0)) .map(|p| p.1); + let mut s = state.lock(); + if running.is_some() != s.awake.is_some() { + s.awake = running.is_some().then(crate::platform::keep_awake); + } + drop(s); Poll { setting_up: setting_up || setup_percent.is_some(), setup_percent, diff --git a/src-tauri/src/commands/mod.rs b/src-tauri/src/commands/mod.rs index 7d8ba75..0812411 100644 --- a/src-tauri/src/commands/mod.rs +++ b/src-tauri/src/commands/mod.rs @@ -94,6 +94,8 @@ struct Shared { /// shortcut: holds one failure, so of several within one poll only the last shows; a list if that happens. failed: Option, watch: Option, + /// Held while a game runs (Steam's or the watched one), so the PC doesn't sleep under it. + awake: Option, /// Steam rejected the saved token; the Settings dot asks the owner to connect again. steam_attention: bool, /// An owned-games fetch is in flight. diff --git a/src-tauri/src/msg.rs b/src-tauri/src/msg.rs index 4a53bf8..02013ec 100644 --- a/src-tauri/src/msg.rs +++ b/src-tauri/src/msg.rs @@ -115,6 +115,7 @@ const EN: &[(&str, &str)] = &[ ("updated", "Updated"), ("repaired", "Repaired"), ("filesVerified", "Files verified"), + ("gameRunning", "A game is running"), ]; /// Dutch, as in `src/lib/i18n/nl.json`. @@ -130,6 +131,7 @@ const NL: &[(&str, &str)] = &[ ("updated", "Bijgewerkt"), ("repaired", "Hersteld"), ("filesVerified", "Bestanden gecontroleerd"), + ("gameRunning", "Er draait een game"), ]; /// The languages with words, by code; the Language setting is one of these or "system". diff --git a/src-tauri/src/platform.rs b/src-tauri/src/platform.rs index 7f6fb20..8bbde1a 100644 --- a/src-tauri/src/platform.rs +++ b/src-tauri/src/platform.rs @@ -104,6 +104,81 @@ pub fn tray_icon_dir() -> Option { ) } +/// Holds off system sleep and screen blanking until dropped. Guild exiting or crashing ends it too: the hold +/// belongs to its thread (Windows) or its session bus connection (Linux). +pub struct Awake(#[allow(dead_code)] std::sync::mpsc::Sender<()>); + +/// Starts an `Awake` hold on its own thread, so a desktop that doesn't answer never stalls the caller. +pub fn keep_awake() -> Awake { + let (hold, released) = std::sync::mpsc::channel(); + if let Err(e) = std::thread::Builder::new() + .name("awake".into()) + .spawn(move || hold_awake(&released)) + { + tracing::warn!("keep awake: {e}"); + } + Awake(hold) +} + +/// Holds until `released` disconnects. The request is per thread, so it is set and cleared on this one. +#[cfg(windows)] +fn hold_awake(released: &std::sync::mpsc::Receiver<()>) { + use windows_sys::Win32::System::Power::{ + ES_CONTINUOUS, ES_DISPLAY_REQUIRED, ES_SYSTEM_REQUIRED, SetThreadExecutionState, + }; + // SAFETY: plain flags in, the previous state out. + if unsafe { SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED) } + == 0 + { + tracing::warn!("keep awake: Windows refused the request"); + return; + } + _ = released.recv(); + // SAFETY: as above. + unsafe { SetThreadExecutionState(ES_CONTINUOUS) }; +} + +/// Holds through the desktop portal's idle Inhibit (KDE, GNOME and others; allowed in the Flatpak without a talk-name) +/// until `released` disconnects. Without a portal the game just runs. +#[cfg(target_os = "linux")] +fn hold_awake(released: &std::sync::mpsc::Receiver<()>) { + use zbus::zvariant::{OwnedObjectPath, Value}; + // Idle only: it keeps the screen on and stops idle suspend, like Windows' request; the gtk backend refuses the + // suspend flag, which would also block a suspend the owner asks for. + const IDLE: u32 = 8; + let inhibit = || -> zbus::Result<(zbus::blocking::Connection, OwnedObjectPath)> { + let bus = zbus::blocking::Connection::session()?; + let options = std::collections::HashMap::from([( + "reason", + Value::from(crate::msg::native("gameRunning")), + )]); + let reply = bus.call_method( + Some("org.freedesktop.portal.Desktop"), + "/org/freedesktop/portal/desktop", + Some("org.freedesktop.portal.Inhibit"), + "Inhibit", + &("", IDLE, options), + )?; + let request = reply.body().deserialize()?; + Ok((bus, request)) + }; + let (bus, request) = match inhibit() { + Ok(held) => held, + Err(e) => return tracing::warn!("keep awake: {e}"), + }; + _ = released.recv(); + let closed = bus.call_method( + Some("org.freedesktop.portal.Desktop"), + &request, + Some("org.freedesktop.portal.Request"), + "Close", + &(), + ); + if let Err(e) = closed { + tracing::warn!("keep awake: release: {e}"); + } +} + /// Whether process `pid` runs and is named `image` (the name guards against a reused pid). #[cfg(windows)] pub fn pid_is(pid: u32, image: &str) -> bool { diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json index ff616c5..671c9dd 100644 --- a/src/lib/i18n/en.json +++ b/src/lib/i18n/en.json @@ -150,6 +150,7 @@ "msg.updated": "Updated", "msg.repaired": "Repaired", "msg.filesVerified": "Files verified", + "msg.gameRunning": "A game is running", "group.favorites": "Favorites", "group.allGames": "All games", "group.today": "Today", diff --git a/src/lib/i18n/nl.json b/src/lib/i18n/nl.json index ef33679..36f631a 100644 --- a/src/lib/i18n/nl.json +++ b/src/lib/i18n/nl.json @@ -150,6 +150,7 @@ "msg.updated": "Bijgewerkt", "msg.repaired": "Hersteld", "msg.filesVerified": "Bestanden gecontroleerd", + "msg.gameRunning": "Er draait een game", "group.favorites": "Favorieten", "group.allGames": "Alle games", "group.today": "Vandaag", From de09ee0e83aa014c0eceebb65197417bd7fc3381 Mon Sep 17 00:00:00 2001 From: TheBiemGamer <47662596+TheBiemGamer@users.noreply.github.com> Date: Mon, 16 Nov 2026 13:36:06 +0000 Subject: [PATCH 2/4] feat(linux): start on login in the Flatpak through the Background portal The sandbox can't write the host's autostart folder, so the switch was hidden. In a Flatpak it now asks the desktop portal's Background interface (autostart with guild --minimized) and keeps the answer in settings, since the entry it writes is out of reach. Outside the Flatpak nothing changes. --- DEVELOPMENT.md | 2 +- src-tauri/src/commands/settings.rs | 20 +++++++++-- src-tauri/src/platform.rs | 57 ++++++++++++++++++++++++++++++ src-tauri/src/settings.rs | 12 ++++++- src/lib/Settings.svelte | 14 ++++---- src/lib/bindings.ts | 2 +- src/lib/i18n/en.json | 1 + src/lib/i18n/nl.json | 1 + 8 files changed, 96 insertions(+), 13 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 3052836..444a7ad 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -98,7 +98,7 @@ flatpak build-bundle --runtime-repo=https://dl.flathub.org/repo/flathub.flatpakr flatpak run --command=flatpak-builder-lint org.flatpak.Builder manifest cloud.biem.guild.yml ``` -Install the bundle on another PC with `flatpak install --user guild.flatpak` (it fetches the runtime from Flathub) and start it with `flatpak run cloud.biem.guild`. A bundle has no remote, so Flatpak doesn't fetch the 32-bit extensions Windows games need; install them once with `flatpak install --user flathub org.freedesktop.Platform.Compat.i386//26.08 org.freedesktop.Platform.GL32.default//26.08` (on NVIDIA, the `GL32.nvidia-*` that matches the driver instead of `GL32.default`). In a Flatpak, Guild doesn't check for updates and hides the autostart switch, and it trusts Steam's `RunningAppID` without checking for the Steam process, which the sandbox can't see. It reads Steam folders and installs to `~/Games`, `/mnt`, `/media` and `/run/media`; give it other folders with `flatpak override --user --filesystem= cloud.biem.guild`. +Install the bundle on another PC with `flatpak install --user guild.flatpak` (it fetches the runtime from Flathub) and start it with `flatpak run cloud.biem.guild`. A bundle has no remote, so Flatpak doesn't fetch the 32-bit extensions Windows games need; install them once with `flatpak install --user flathub org.freedesktop.Platform.Compat.i386//26.08 org.freedesktop.Platform.GL32.default//26.08` (on NVIDIA, the `GL32.nvidia-*` that matches the driver instead of `GL32.default`). In a Flatpak, Guild doesn't check for updates, asks the desktop portal's Background interface to start it on login (the desktop may ask first), and it trusts Steam's `RunningAppID` without checking for the Steam process, which the sandbox can't see. It reads Steam folders and installs to `~/Games`, `/mnt`, `/media` and `/run/media`; give it other folders with `flatpak override --user --filesystem= cloud.biem.guild`. ## Releasing diff --git a/src-tauri/src/commands/settings.rs b/src-tauri/src/commands/settings.rs index 3513247..5ec1614 100644 --- a/src-tauri/src/commands/settings.rs +++ b/src-tauri/src/commands/settings.rs @@ -336,7 +336,7 @@ pub struct SettingsView { start_with_windows: bool, /// Picks the Linux wording where the Windows one names Windows. linux: bool, - /// A Flatpak hides the autostart switch (the sandbox can't reach the host's autostart folder) and update checks. + /// A Flatpak hides update checks. flatpak: bool, close_to_tray: bool, notify_downloads: bool, @@ -408,7 +408,11 @@ pub async fn settings_view(app: AppHandle) -> Res { ambient: saved.ambient, cloud_saves: saved.cloud_saves, gog_cloud_saves: saved.gog_cloud_saves, - start_with_windows: app.autolaunch().is_enabled().unwrap_or(false), + start_with_windows: if crate::platform::flatpak() { + settings::portal_autostart(&conn) + } else { + app.autolaunch().is_enabled().unwrap_or(false) + }, linux: cfg!(target_os = "linux"), flatpak: crate::platform::flatpak(), close_to_tray: saved.close_to_tray, @@ -443,6 +447,18 @@ pub async fn update_setting(app: AppHandle, name: String, value: Option) blocking(move || { if name == settings::START_WITH_WINDOWS { settings::validate(&name, value.as_deref())?; + if crate::platform::flatpak() { + let on = value.as_deref() == Some("true"); + let now = crate::platform::portal_autostart(on) + .map_err(|e| msg!(cantChangeAutostart, detail = e))?; + let conn = cache::db::open(&app.state::().dirs.db)?; + settings::update(&conn, &name, Some(&now.to_string()))?; + return if now == on { + Ok(()) + } else { + Err(msg!(autostartNotAllowed)) + }; + } let autostart = app.autolaunch(); let done = if value.as_deref() == Some("true") { autostart.enable() diff --git a/src-tauri/src/platform.rs b/src-tauri/src/platform.rs index 8bbde1a..692fdd8 100644 --- a/src-tauri/src/platform.rs +++ b/src-tauri/src/platform.rs @@ -891,6 +891,63 @@ pub fn remove_autostart(_name: &str) -> std::io::Result<()> { Ok(()) } +/// Windows has no Flatpak; its autostart is tauri-plugin-autostart's. +#[cfg(windows)] +pub fn portal_autostart(_on: bool) -> Result { + Err("no portal on Windows".into()) +} + +/// Asks the desktop portal's Background interface to start Guild on login (`on`) or not, since a Flatpak can't +/// write the host's autostart folder. The desktop may ask the owner first. Returns whether autostart is now on. +#[cfg(target_os = "linux")] +pub fn portal_autostart(on: bool) -> Result { + use std::collections::HashMap; + use zbus::zvariant::{OwnedValue, Value}; + let request = || -> zbus::Result { + let bus = zbus::blocking::Connection::session()?; + // The portal answers on a Request object whose path follows from our bus name and this token; listen first. + static REQUESTS: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(0); + let n = REQUESTS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); + let token = format!("guild{}_{n}", std::process::id()); + let sender = bus + .unique_name() + .map(|n| n.trim_start_matches(':').replace('.', "_")) + .unwrap_or_default(); + let response = zbus::blocking::proxy::Builder::::new(&bus) + .destination("org.freedesktop.portal.Desktop")? + .path(format!( + "/org/freedesktop/portal/desktop/request/{sender}/{token}" + ))? + .interface("org.freedesktop.portal.Request")? + .cache_properties(zbus::proxy::CacheProperties::No) + .build()?; + let mut answers = response.receive_signal("Response")?; + let commandline = vec!["guild", crate::tray::MINIMIZED]; + let options = HashMap::from([ + ("handle_token", Value::from(token.as_str())), + ("autostart", Value::from(on)), + ("commandline", Value::from(commandline)), + ]); + bus.call_method( + Some("org.freedesktop.portal.Desktop"), + "/org/freedesktop/portal/desktop", + Some("org.freedesktop.portal.Background"), + "RequestBackground", + &("", options), + )?; + let answer = answers + .next() + .ok_or_else(|| zbus::Error::Failure("the portal never answered".into()))?; + let (status, results): (u32, HashMap) = answer.body().deserialize()?; + let granted = results + .get("autostart") + .and_then(|v| bool::try_from(v).ok()) + .unwrap_or(false); + Ok(status == 0 && granted) + }; + request().map_err(|e| e.to_string()) +} + /// "Windows 11 (build 26200)", from the registry; builds from 22000 on are Windows 11. #[cfg(windows)] pub fn os_version() -> String { diff --git a/src-tauri/src/settings.rs b/src-tauri/src/settings.rs index 646323f..4182747 100644 --- a/src-tauri/src/settings.rs +++ b/src-tauri/src/settings.rs @@ -17,7 +17,8 @@ pub const CLOSE_TO_TRAY: &str = "close_to_tray"; pub const NOTIFY_DOWNLOADS: &str = "notify_downloads"; /// "system" (Windows' display language), "en" or "nl" (`msg::is_language`). pub const LANGUAGE: &str = "language"; -/// Not stored: the autostart entry in the registry is the truth (`commands::settings`). +/// Stored only in a Flatpak, where the portal writes the host's autostart entry out of Guild's reach; elsewhere +/// the entry itself is the truth (`commands::settings`). pub const START_WITH_WINDOWS: &str = "start_with_windows"; pub const EPIC_INSTALL_DIR: &str = "epic_install_dir"; pub const GOG_INSTALL_DIR: &str = "gog_install_dir"; @@ -129,6 +130,15 @@ pub fn take_updated(conn: &Connection, current: &str) -> Option { seen.map(|_| current.to_string()) } +/// Whether the Background portal was last told to start Guild on login (a Flatpak only). +pub fn portal_autostart(conn: &Connection) -> bool { + db::setting(conn, START_WITH_WINDOWS) + .ok() + .flatten() + .as_deref() + == Some("true") +} + /// Whether the owner logged out of `store` ("epic", "gog", "amazon") with Log out, so its Settings dot stays down /// until it is logged in again. Internal: not in `validate`. pub fn signed_out(conn: &Connection, store: &str) -> bool { diff --git a/src/lib/Settings.svelte b/src/lib/Settings.svelte index 9ea5223..1081a89 100644 --- a/src/lib/Settings.svelte +++ b/src/lib/Settings.svelte @@ -1153,14 +1153,12 @@

{t('settings.section.general')}

{t('settings.group.startup')}

- {#if !view.flatpak} - {@render switchRow( - 'power', - 'start_with_windows', - 'startWithWindows', - view.linux ? t('settings.startupLinux') : t('settings.startup'), - )} - {/if} + {@render switchRow( + 'power', + 'start_with_windows', + 'startWithWindows', + view.linux ? t('settings.startupLinux') : t('settings.startup'), + )} {@render switchRow('tray', 'close_to_tray', 'closeToTray', t('settings.tray'), t('settings.trayHint'))} {@render switchRow('bell', 'notify_downloads', 'notifyDownloads', t('settings.notify'))}
diff --git a/src/lib/bindings.ts b/src/lib/bindings.ts index 8039a31..c021156 100644 --- a/src/lib/bindings.ts +++ b/src/lib/bindings.ts @@ -690,7 +690,7 @@ export type SettingsView = { startWithWindows: boolean, /** Picks the Linux wording where the Windows one names Windows. */ linux: boolean, - /** A Flatpak hides the autostart switch (the sandbox can't reach the host's autostart folder) and update checks. */ + /** A Flatpak hides update checks. */ flatpak: boolean, closeToTray: boolean, notifyDownloads: boolean, diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json index 671c9dd..31b110b 100644 --- a/src/lib/i18n/en.json +++ b/src/lib/i18n/en.json @@ -105,6 +105,7 @@ "msg.unknownTool": "Unknown tool.", "msg.cantChangeStartup": "Couldn't change the Windows startup entry: {detail}", "msg.cantChangeAutostart": "Couldn't change the autostart entry: {detail}", + "msg.autostartNotAllowed": "Your desktop didn't allow Guild to start on login.", "msg.cantClearFolder": "Couldn't clear {path}: {detail}", "msg.notConnecting": "Steam login stopped.", "msg.steamNoAccount": "Steam sent no account name.", diff --git a/src/lib/i18n/nl.json b/src/lib/i18n/nl.json index 36f631a..50acec5 100644 --- a/src/lib/i18n/nl.json +++ b/src/lib/i18n/nl.json @@ -105,6 +105,7 @@ "msg.unknownTool": "Onbekende tool.", "msg.cantChangeStartup": "Kan het opstartitem van Windows niet wijzigen: {detail}", "msg.cantChangeAutostart": "Kan het autostart-item niet wijzigen: {detail}", + "msg.autostartNotAllowed": "Je bureaublad staat niet toe dat Guild start bij inloggen.", "msg.cantClearFolder": "Kan {path} niet leegmaken: {detail}", "msg.notConnecting": "Inloggen bij Steam is gestopt.", "msg.steamNoAccount": "Steam stuurde geen accountnaam.", From f48b82138595ab02bc0c92e87ade7d1cca56bac6 Mon Sep 17 00:00:00 2001 From: TheBiemGamer <47662596+TheBiemGamer@users.noreply.github.com> Date: Mon, 16 Nov 2026 13:41:45 +0000 Subject: [PATCH 3/4] feat(linux): Gamescope, MangoHud and GameMode around games Settings -> Wine gets a switch per tool (off by default) and a game's Launch options a Default / On / Off menu per tool, kept with its other launch options in game_prefs. Windows games wrap umu-run, native Linux builds their own program. A tool that isn't on PATH shows disabled with the reason; the Flatpak finds MangoHud and gamescope in their Flathub Vulkan layer extensions and gamemoderun in the runtime. --- DESIGN.md | 3 +- DEVELOPMENT.md | 4 +- packaging/flatpak/cloud.biem.guild.yml | 5 + src-tauri/src/commands/game.rs | 23 ++- src-tauri/src/commands/settings.rs | 10 ++ ...ngs__tests__settings_payload_snapshot.snap | 3 + src-tauri/src/game_tools.rs | 161 ++++++++++++++++++ src-tauri/src/library/amazon.rs | 7 +- src-tauri/src/library/custom.rs | 15 +- src-tauri/src/library/epic.rs | 8 +- src-tauri/src/library/gog.rs | 8 +- src-tauri/src/library/tool.rs | 4 + src-tauri/src/main.rs | 3 + src-tauri/src/platform.rs | 50 +++++- src-tauri/src/settings.rs | 15 +- src-tauri/src/wine.rs | 9 +- src/lib/Detail.svelte | 54 +++++- src/lib/Settings.svelte | 37 +++- src/lib/bindings.ts | 19 +++ src/lib/i18n/en.json | 7 + src/lib/i18n/nl.json | 7 + 21 files changed, 409 insertions(+), 43 deletions(-) create mode 100644 src-tauri/src/game_tools.rs diff --git a/DESIGN.md b/DESIGN.md index 7cf8c6d..2b6b1cd 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -220,10 +220,11 @@ No UI text below 11px. Counts and numbers use tabular figures. Folder paths in t - **Toolbar,** left to right: search, store selector, Installed, active filter chips, Filters, spacer, Sort, Update (only when one is ready), Downloads (only while something downloads), Add a game, Settings. No sidebar. - **Settings:** a modal panel, max 760px wide, with a 190px section list on the left (stacked under 640px) that works as vertical tabs: only the chosen section shows, from its top. Sections: Accounts (Stores, then Game data with IGDB and SteamGridDB), General, About. Each section is a title, then Label headings over one rounded `glass` group per heading, its rows split by `glass-line` rules. Never a box per row. About opens with the 64px app logo beside Guild and its version, the acronym in small italic `text-3`, one line on what Guild is for, and Source code · GPL-3.0 · Credits (the README's Thanks); its Updates row then says only what the last check found. On Linux a Wine section sits between General and About (Windows never shows it), direction A (2026-11-09): - The top group: an umu-launcher row with Install only while umu is missing, then Proton for Windows games, one menu (Newest, naming the build that is now, then each build) with the subtitle that a game's own choice in Launch options comes first. + - Game tools: Gamescope, MangoHud and GameMode, one switch row each (name, one line on what it does), off by default, and a note that a game's own choice in Launch options comes first. A tool that isn't installed shows its switch disabled and "Not installed" in the row, or in the Flatpak the Flathub extension to install. - Proton builds: one row per build, by a readable name where the folder name allows ("Proton-CachyOS 11.0 (v3)", `protonName` in `format.ts`), with an accent "in use" tag on the build games run with, a "Steam" tag on Steam's, its size once measured, and Remove with an inline confirm for Guild's own only. The last row, Install another build, folds out one panel with a GE-Proton / Proton-CachyOS segmented control and that source's releases, each with Install (its percent while it runs) or Installed. - Prefixes: the heading carries the count and total size on the right. One row per game prefix with its name (the copy key and "Game no longer in your library" once the game is gone), its size once measured, and a ⋯ menu with Open folder, winecfg, winetricks (disabled when neither the system nor any Proton build has it; a note under the group says why) and Remove…, which asks in the row that saves in it are lost unless cloud saves are on, with focus on Cancel. - Rows in these two lists are one height, with or without a button. -- **Game page:** covers the content area while the library stays mounted underneath, so its scroll position survives. A column up to 1360px: the 300px hero, a tab row (Overview, DLC, Saves, Launch options, Installation); on Linux, Launch options adds a Proton menu chip (Default follows Settings), also for added games, where it is the only row, and never for a native Linux GOG build. A Windows game's first launch on Linux shows Setting up… in the busy pill, the card badge and Continue until its program runs, with the percent while its Play downloads umu-launcher or GE-Proton first. Once a Windows game has run on Linux, Installation gets a Wine prefix row with Open, winecfg and winetricks (disabled with the same reason as in Settings); never for a native Linux build, and never Remove, which stays in Settings and the uninstall confirm. Its uninstall confirm offers an Also remove its Wine prefix checkbox, off by default, then three fact tiles and an About / Details grid (1.7fr / 1fr). +- **Game page:** covers the content area while the library stays mounted underneath, so its scroll position survives. A column up to 1360px: the 300px hero, a tab row (Overview, DLC, Saves, Launch options, Installation); on Linux, Launch options adds a Proton menu chip (Default follows Settings), also for added games, and never for a native Linux GOG build; then Gamescope, MangoHud and GameMode rows, each a Default / On / Off menu chip (Default follows Settings), for every game including native ones; a tool that isn't installed shows a disabled Off chip and "Not installed". A Windows game's first launch on Linux shows Setting up… in the busy pill, the card badge and Continue until its program runs, with the percent while its Play downloads umu-launcher or GE-Proton first. Once a Windows game has run on Linux, Installation gets a Wine prefix row with Open, winecfg and winetricks (disabled with the same reason as in Settings); never for a native Linux build, and never Remove, which stays in Settings and the uninstall confirm. Its uninstall confirm offers an Also remove its Wine prefix checkbox, off by default, then three fact tiles and an About / Details grid (1.7fr / 1fr). ## Elevation and shapes diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 444a7ad..c8b4c95 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -10,7 +10,7 @@ You need [Node.js](https://nodejs.org) 24 or later, [Rust](https://rustup.rs) st sudo apt install libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev libxdo-dev libssl-dev patchelf build-essential ``` -On Arch: `webkit2gtk-4.1 libayatana-appindicator librsvg xdotool base-devel`. At runtime Linux also needs `python3` (the Linux builds of Legendary and gogdl run on it), `xdg-open`, and a Secret Service provider such as GNOME Keyring or KWallet for the saved secrets. Windows games run through `umu-run` (from PATH, or downloaded in Settings or by the first Play that needs it) and a Proton build: GE-Proton in Steam's `compatibilitytools.d`, Steam's own Proton, or GE-Proton and Proton-CachyOS installed from Settings → Wine; with none, Play installs the newest GE-Proton. Each game gets its own Wine prefix under `/prefixes/`; uninstalling a game keeps it unless the owner ticks the option to remove it, since its saves live there. Settings → Wine lists and removes prefixes. The pinned umu-launcher version and hash are in `src-tauri/src/wine.rs`. +On Arch: `webkit2gtk-4.1 libayatana-appindicator librsvg xdotool base-devel`. At runtime Linux also needs `python3` (the Linux builds of Legendary and gogdl run on it), `xdg-open`, and a Secret Service provider such as GNOME Keyring or KWallet for the saved secrets. Windows games run through `umu-run` (from PATH, or downloaded in Settings or by the first Play that needs it) and a Proton build: GE-Proton in Steam's `compatibilitytools.d`, Steam's own Proton, or GE-Proton and Proton-CachyOS installed from Settings → Wine; with none, Play installs the newest GE-Proton. Gamescope, MangoHud and GameMode (`gamescope`, `mangohud`, `gamemoderun` on PATH) wrap Windows and native games when switched on in Settings → Wine or a game's Launch options. Each game gets its own Wine prefix under `/prefixes/`; uninstalling a game keeps it unless the owner ticks the option to remove it, since its saves live there. Settings → Wine lists and removes prefixes. The pinned umu-launcher version and hash are in `src-tauri/src/wine.rs`. ```bash npm install @@ -98,7 +98,7 @@ flatpak build-bundle --runtime-repo=https://dl.flathub.org/repo/flathub.flatpakr flatpak run --command=flatpak-builder-lint org.flatpak.Builder manifest cloud.biem.guild.yml ``` -Install the bundle on another PC with `flatpak install --user guild.flatpak` (it fetches the runtime from Flathub) and start it with `flatpak run cloud.biem.guild`. A bundle has no remote, so Flatpak doesn't fetch the 32-bit extensions Windows games need; install them once with `flatpak install --user flathub org.freedesktop.Platform.Compat.i386//26.08 org.freedesktop.Platform.GL32.default//26.08` (on NVIDIA, the `GL32.nvidia-*` that matches the driver instead of `GL32.default`). In a Flatpak, Guild doesn't check for updates, asks the desktop portal's Background interface to start it on login (the desktop may ask first), and it trusts Steam's `RunningAppID` without checking for the Steam process, which the sandbox can't see. It reads Steam folders and installs to `~/Games`, `/mnt`, `/media` and `/run/media`; give it other folders with `flatpak override --user --filesystem= cloud.biem.guild`. +Install the bundle on another PC with `flatpak install --user guild.flatpak` (it fetches the runtime from Flathub) and start it with `flatpak run cloud.biem.guild`. A bundle has no remote, so Flatpak doesn't fetch the 32-bit extensions Windows games need; install them once with `flatpak install --user flathub org.freedesktop.Platform.Compat.i386//26.08 org.freedesktop.Platform.GL32.default//26.08` (on NVIDIA, the `GL32.nvidia-*` that matches the driver instead of `GL32.default`). In a Flatpak, Guild doesn't check for updates, asks the desktop portal's Background interface to start it on login (the desktop may ask first), and it trusts Steam's `RunningAppID` without checking for the Steam process, which the sandbox can't see. For MangoHud and gamescope, install their Flathub extensions: `flatpak install --user flathub org.freedesktop.Platform.VulkanLayer.MangoHud//26.08 org.freedesktop.Platform.VulkanLayer.gamescope//26.08`; GameMode needs only the `gamemoded` daemon on the host. It reads Steam folders and installs to `~/Games`, `/mnt`, `/media` and `/run/media`; give it other folders with `flatpak override --user --filesystem= cloud.biem.guild`. ## Releasing diff --git a/packaging/flatpak/cloud.biem.guild.yml b/packaging/flatpak/cloud.biem.guild.yml index 4eb1844..4e29ccc 100644 --- a/packaging/flatpak/cloud.biem.guild.yml +++ b/packaging/flatpak/cloud.biem.guild.yml @@ -24,6 +24,11 @@ finish-args: - --talk-name=org.kde.StatusNotifierWatcher # Download-finished notifications - --talk-name=org.freedesktop.Notifications + # MangoHud and gamescope from their Flathub Vulkan layer extensions, when installed; gamemoderun is in the runtime + - --env=PATH=/app/bin:/usr/bin:/usr/lib/extensions/vulkan/MangoHud/bin:/usr/lib/extensions/vulkan/gamescope/bin + - --env=LD_LIBRARY_PATH=/usr/lib/extensions/vulkan/gamescope/lib + - --filesystem=xdg-run/gamescope-0 + - --filesystem=xdg-config/MangoHud:ro # Steam: its library, pid, registry.vdf and art (regular and Flatpak Steam); Guild never writes there - --filesystem=~/.steam:ro - --filesystem=xdg-data/Steam:ro diff --git a/src-tauri/src/commands/game.rs b/src-tauri/src/commands/game.rs index 8045558..cb00b62 100644 --- a/src-tauri/src/commands/game.rs +++ b/src-tauri/src/commands/game.rs @@ -594,8 +594,8 @@ fn act_custom(state: &AppState, action: Action, game: &Game) -> Res<()> { let row = cache::db::custom_game(&conn, &game.external_id)?.ok_or(msg!(gameNotInLibrary))?; let key = game.key(); - let proton = launch_options_of(&conn, &game.key()).proton; - crate::library::custom::launch(&row, proton.as_deref()).map(|child| { + let options = launch_options_of(&conn, &game.key()); + crate::library::custom::launch(&row, &options).map(|child| { record_play(state, &key); state.lock().watch = Some(Watch { key, @@ -974,6 +974,13 @@ pub async fn protons(app: AppHandle, key: String) -> Vec { .await } +/// Linux: the game tools installed, for a game's Launch options; `None` on Windows. +#[tauri::command] +#[specta::specta] +pub async fn game_tools() -> Option { + blocking(crate::platform::game_tools).await +} + /// A GOG game installed as its native Linux build, which runs without Proton. pub(super) fn native_build(game: &Game) -> bool { game.provider == ProviderKind::Gog && installed_dir(game).is_some_and(|dir| gog::native(dir)) @@ -1006,8 +1013,11 @@ pub async fn set_launch_options( if game.provider == ProviderKind::Custom { // An added game keeps its program and arguments itself. options = LaunchOptions { - proton: options.proton, - ..LaunchOptions::default() + args: String::new(), + offline: false, + skip_version_check: false, + exe: None, + ..options }; } blocking(move || { @@ -2282,6 +2292,9 @@ mod tests { skip_version_check: false, exe: Some(r"bin\game.exe".into()), proton: Some("GE-Proton11-12".into()), + gamescope: None, + mangohud: Some(true), + gamemode: Some(false), }; store_launch_options(&conn, "epic-A", &options).unwrap(); assert_eq!(launch_options_of(&conn, "epic-A"), options); @@ -2291,7 +2304,7 @@ mod tests { .unwrap(); assert_eq!( json, - r#"{"args":"-dx11","offline":true,"skipVersionCheck":false,"exe":"bin\\game.exe","proton":"GE-Proton11-12"}"# + r#"{"args":"-dx11","offline":true,"skipVersionCheck":false,"exe":"bin\\game.exe","proton":"GE-Proton11-12","gamescope":null,"mangohud":true,"gamemode":false}"# ); store_launch_options(&conn, "epic-A", &LaunchOptions::default()).unwrap(); assert_eq!( diff --git a/src-tauri/src/commands/settings.rs b/src-tauri/src/commands/settings.rs index 5ec1614..413fc24 100644 --- a/src-tauri/src/commands/settings.rs +++ b/src-tauri/src/commands/settings.rs @@ -338,6 +338,10 @@ pub struct SettingsView { linux: bool, /// A Flatpak hides update checks. flatpak: bool, + /// Linux: gamescope, MangoHud and GameMode for every game unless its launch options say otherwise. + use_gamescope: bool, + use_mangohud: bool, + use_gamemode: bool, close_to_tray: bool, notify_downloads: bool, app_version: String, @@ -415,6 +419,9 @@ pub async fn settings_view(app: AppHandle) -> Res { }, linux: cfg!(target_os = "linux"), flatpak: crate::platform::flatpak(), + use_gamescope: saved.game_tools.gamescope, + use_mangohud: saved.game_tools.mangohud, + use_gamemode: saved.game_tools.gamemode, close_to_tray: saved.close_to_tray, notify_downloads: saved.notify_downloads, app_version: app.package_info().version.to_string(), @@ -1090,6 +1097,9 @@ mod tests { start_with_windows: false, linux: false, flatpak: false, + use_gamescope: false, + use_mangohud: false, + use_gamemode: false, close_to_tray: true, notify_downloads: true, app_version: env!("CARGO_PKG_VERSION").into(), diff --git a/src-tauri/src/commands/snapshots/launcher__commands__settings__tests__settings_payload_snapshot.snap b/src-tauri/src/commands/snapshots/launcher__commands__settings__tests__settings_payload_snapshot.snap index 383c625..d6ed6bf 100644 --- a/src-tauri/src/commands/snapshots/launcher__commands__settings__tests__settings_payload_snapshot.snap +++ b/src-tauri/src/commands/snapshots/launcher__commands__settings__tests__settings_payload_snapshot.snap @@ -30,6 +30,9 @@ expression: view "startWithWindows": false, "linux": false, "flatpak": false, + "useGamescope": false, + "useMangohud": false, + "useGamemode": false, "closeToTray": true, "notifyDownloads": true, "appVersion": "[version]", diff --git a/src-tauri/src/game_tools.rs b/src-tauri/src/game_tools.rs new file mode 100644 index 0000000..0abc9b8 --- /dev/null +++ b/src-tauri/src/game_tools.rs @@ -0,0 +1,161 @@ +//! Gamescope, MangoHud and GameMode around a game on Linux, Windows games (around umu-run) and native ones alike. Each +//! is on when the game's own launch options say so, else when Settings does, and only when it is installed. In the +//! Flatpak, MangoHud and gamescope come from their Flathub Vulkan layer extensions and GameMode from the runtime. + +use std::process::Command; + +use crate::cache::{Dirs, db}; +use crate::library::tool::LaunchOptions; +use crate::platform::GameTools; + +const GAMESCOPE: &str = "gamescope"; +const MANGOHUD: &str = "mangohud"; +const GAMEMODE: &str = "gamemoderun"; + +/// The tools found on PATH. +pub fn installed() -> GameTools { + let found = |name| crate::wine::on_path(name).is_some(); + GameTools { + gamescope: found(GAMESCOPE), + mangohud: found(MANGOHUD), + gamemode: found(GAMEMODE), + } +} + +/// The tools a game runs with: its own choice, else the setting, and installed. +pub fn chosen(options: &LaunchOptions) -> GameTools { + let settings = db::open(&Dirs::new().db) + .map(|conn| crate::settings::load(&conn).game_tools) + .unwrap_or_else(|e| { + tracing::warn!("game tools: {e}"); + GameTools::default() + }); + pick(options, &settings, installed()) +} + +fn pick(options: &LaunchOptions, settings: &GameTools, installed: GameTools) -> GameTools { + GameTools { + gamescope: options.gamescope.unwrap_or(settings.gamescope) && installed.gamescope, + mangohud: options.mangohud.unwrap_or(settings.mangohud) && installed.mangohud, + gamemode: options.gamemode.unwrap_or(settings.gamemode) && installed.gamemode, + } +} + +/// `game` with the chosen tools in front, outermost first: gamescope (fullscreen at the screen's size; MangoHud then +/// draws through its `--mangoapp`), MangoHud, gamemoderun. +pub fn wrap(game: Command, tools: GameTools) -> Command { + let mut front: Vec<&str> = Vec::new(); + if tools.gamescope { + front.extend([GAMESCOPE, "-f"]); + if tools.mangohud { + front.push("--mangoapp"); + } + front.push("--"); + } else if tools.mangohud { + // --dlsym also reaches OpenGL games that load their GL library themselves. + front.extend([MANGOHUD, "--dlsym"]); + } + if tools.gamemode { + front.push(GAMEMODE); + } + let Some((program, args)) = front.split_first() else { + return game; + }; + let mut command = Command::new(program); + command + .args(args) + .arg(game.get_program()) + .args(game.get_args()); + if let Some(dir) = game.get_current_dir() { + command.current_dir(dir); + } + for (name, value) in game.get_envs() { + match value { + Some(value) => command.env(name, value), + None => command.env_remove(name), + }; + } + command +} + +#[cfg(test)] +mod tests { + use super::*; + use std::ffi::OsString; + + fn argv(c: &Command) -> Vec { + std::iter::once(c.get_program().to_owned()) + .chain(c.get_args().map(ToOwned::to_owned)) + .collect() + } + + fn game() -> Command { + let mut c = Command::new("umu-run"); + c.arg("Game.exe").current_dir("/g").env("WINEPREFIX", "/p"); + c + } + + const ALL: GameTools = GameTools { + gamescope: true, + mangohud: true, + gamemode: true, + }; + + #[test] + fn wraps_outermost_first_and_keeps_folder_and_variables() { + let c = wrap(game(), ALL); + assert_eq!( + argv(&c), + [ + "gamescope", + "-f", + "--mangoapp", + "--", + "gamemoderun", + "umu-run", + "Game.exe" + ] + ); + assert_eq!(c.get_current_dir(), Some(std::path::Path::new("/g"))); + assert!( + c.get_envs() + .any(|(k, v)| k == "WINEPREFIX" && v == Some("/p".as_ref())) + ); + let mangohud = GameTools { + mangohud: true, + ..GameTools::default() + }; + assert_eq!( + argv(&wrap(game(), mangohud)), + ["mangohud", "--dlsym", "umu-run", "Game.exe"] + ); + assert_eq!( + argv(&wrap(game(), GameTools::default())), + ["umu-run", "Game.exe"] + ); + } + + #[test] + fn the_game_choice_beats_settings_and_missing_tools_stay_off() { + let options = LaunchOptions { + gamescope: Some(false), + mangohud: Some(true), + ..LaunchOptions::default() + }; + let settings = GameTools { + gamescope: true, + mangohud: false, + gamemode: true, + }; + assert_eq!( + pick(&options, &settings, ALL), + GameTools { + gamescope: false, + mangohud: true, + gamemode: true, + } + ); + let none = GameTools::default(); + assert_eq!(pick(&options, &settings, none), none); + } +} diff --git a/src-tauri/src/library/amazon.rs b/src-tauri/src/library/amazon.rs index 972b3e1..44ea1ae 100644 --- a/src-tauri/src/library/amazon.rs +++ b/src-tauri/src/library/amazon.rs @@ -1161,11 +1161,8 @@ pub fn launch(id: &str, dir: &Path, options: &LaunchOptions) -> Result Command { } /// Starts the program and returns its process, to watch. Doesn't wait for it. On Linux the .exe runs through the -/// runner (`platform::windows_game`) with `proton`, the game's own choice, else the one chosen in Settings. -pub fn launch(c: &CustomGame, proton: Option<&str>) -> Result { +/// runner (`platform::windows_game`) with its own launch options (its Proton and game tools), else Settings'. +pub fn launch(c: &CustomGame, options: &LaunchOptions) -> Result { check_exe(&c.exe).map_err(|_| missing(&c.name))?; let key = ProviderKind::Custom.key(&c.id); - Ok(crate::platform::windows_game(command(c), &key, proton)?.spawn()?) + Ok(crate::platform::windows_game(command(c), &key, options)?.spawn()?) } #[cfg(test)] @@ -200,7 +201,13 @@ mod tests { assert!(check_exe(&exe.to_string_lossy()).is_ok()); assert!(check_exe(&bat.to_string_lossy()).is_err()); assert!(check_exe(&dir.join("gone.exe").to_string_lossy()).is_err()); - assert!(launch(&row(&dir.join("gone.exe").to_string_lossy(), ""), None).is_err()); + assert!( + launch( + &row(&dir.join("gone.exe").to_string_lossy(), ""), + &LaunchOptions::default() + ) + .is_err() + ); } #[test] diff --git a/src-tauri/src/library/epic.rs b/src-tauri/src/library/epic.rs index f1866b4..4ba7cd3 100644 --- a/src-tauri/src/library/epic.rs +++ b/src-tauri/src/library/epic.rs @@ -138,11 +138,7 @@ pub fn launch( args.splice(2..2, ["--no-wine".to_string(), "--json".to_string()]); let args: Vec<&str> = args.iter().map(String::as_str).collect(); let game = launch_command(&json(&args)?).ok_or(msg!(legendaryNoReason))?; - let mut game = crate::platform::windows_game( - game, - &ProviderKind::Epic.key(app_name), - options.proton.as_deref(), - )?; + let mut game = crate::platform::windows_game(game, &ProviderKind::Epic.key(app_name), options)?; Ok(Some(game.spawn()?)) } @@ -892,7 +888,7 @@ mod tests { offline: true, skip_version_check: true, exe: Some(r"bin\game.exe".into()), - proton: None, + ..LaunchOptions::default() }; assert_eq!( launch_args("Fn", &all, false), diff --git a/src-tauri/src/library/gog.rs b/src-tauri/src/library/gog.rs index 2d660e5..5c74bff 100644 --- a/src-tauri/src/library/gog.rs +++ b/src-tauri/src/library/gog.rs @@ -1257,13 +1257,9 @@ pub fn launch(id: &str, dir: &Path, options: &LaunchOptions) -> Result, /// Linux: the Proton build this game runs with, by folder name; none follows Settings. pub proton: Option, + /// Linux: whether it runs in gamescope, with MangoHud, with GameMode; none follows Settings. + pub gamescope: Option, + pub mangohud: Option, + pub gamemode: Option, } /// Splits typed arguments on whitespace; double quotes group. No shell, no variables. diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 9c401a1..a6f089d 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -12,6 +12,8 @@ mod downloads; mod entries; mod epic_login; mod epic_playtime; +#[cfg(target_os = "linux")] +mod game_tools; mod gamesdb; mod gog_login; mod igdb; @@ -127,6 +129,7 @@ fn bindings() -> tauri_specta::Builder { commands::game::set_saves, commands::game::sync_saves_now, commands::game::launch_options, + commands::game::game_tools, commands::game::set_launch_options, commands::game::open_steam_properties, commands::library::poll, diff --git a/src-tauri/src/platform.rs b/src-tauri/src/platform.rs index 692fdd8..715e946 100644 --- a/src-tauri/src/platform.rs +++ b/src-tauri/src/platform.rs @@ -627,6 +627,16 @@ pub struct RunnerView { pub protons: Vec, pub proton: Option, pub winetricks: bool, + /// The game tools installed (`GameTools`). + pub tools: GameTools, +} + +/// Linux: gamescope, MangoHud and GameMode, as chosen in Settings, as installed, or as a game runs with. +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, serde::Serialize, specta::Type)] +pub struct GameTools { + pub gamescope: bool, + pub mangohud: bool, + pub gamemode: bool, } /// A Proton build found; only Guild's own may be removed. @@ -676,24 +686,54 @@ pub fn protons() -> Vec { crate::wine::proton_names() } -/// A Windows game's program as it runs: as is on Windows. `key` is its copy key, `proton` its own Proton choice. +/// A Windows game's program as it runs: as is on Windows. `key` is its copy key, `options` its launch options. #[cfg(windows)] pub fn windows_game( game: std::process::Command, _key: &str, - _proton: Option<&str>, + _options: &crate::library::tool::LaunchOptions, ) -> Result { Ok(game) } -/// A Windows game's program as it runs: through umu-launcher and Proton, in the copy's own Wine prefix. +/// A Windows game's program as it runs: through umu-launcher and its Proton choice, in the copy's own Wine prefix, +/// inside its game tools. #[cfg(target_os = "linux")] pub fn windows_game( game: std::process::Command, key: &str, - proton: Option<&str>, + options: &crate::library::tool::LaunchOptions, ) -> Result { - crate::wine::game_command(game, key, proton) + crate::wine::game_command(game, key, options) +} + +/// A native game's program as it runs: as is on Windows. +#[cfg(windows)] +pub fn native_game( + game: std::process::Command, + _options: &crate::library::tool::LaunchOptions, +) -> std::process::Command { + game +} + +/// A native Linux game's program as it runs: inside its game tools. +#[cfg(target_os = "linux")] +pub fn native_game( + game: std::process::Command, + options: &crate::library::tool::LaunchOptions, +) -> std::process::Command { + crate::game_tools::wrap(game, crate::game_tools::chosen(options)) +} + +/// The game tools installed; `None` on Windows, which has none. +#[cfg(windows)] +pub fn game_tools() -> Option { + None +} + +#[cfg(target_os = "linux")] +pub fn game_tools() -> Option { + Some(crate::game_tools::installed()) } /// The copy whose Play installs umu-launcher or Proton first, and the download's percent; never on Windows. diff --git a/src-tauri/src/settings.rs b/src-tauri/src/settings.rs index 4182747..57981b5 100644 --- a/src-tauri/src/settings.rs +++ b/src-tauri/src/settings.rs @@ -25,6 +25,10 @@ pub const GOG_INSTALL_DIR: &str = "gog_install_dir"; pub const AMAZON_INSTALL_DIR: &str = "amazon_install_dir"; /// Linux: the Proton build Windows games run with, by folder name (`wine`); none is the newest found. pub const PROTON: &str = "proton"; +/// Linux: whether games run in gamescope, with MangoHud or with GameMode unless their launch options say otherwise. +pub const GAMESCOPE: &str = "gamescope"; +pub const MANGOHUD: &str = "mangohud"; +pub const GAMEMODE: &str = "gamemode"; pub const IGDB_CLIENT_ID: &str = "igdb_client_id"; /// The library's sort, as the toolbar last left it (serde names: `mostPlayed`, `longestToBeat`). It sets /// the grouping too. An old `library_group` row is left alone and ignored. @@ -53,9 +57,11 @@ pub struct Settings { pub sort: Sort, /// The Language setting as saved; `msg::resolve` turns it into a language. pub language: String, + /// Linux: gamescope, MangoHud and GameMode for every game; off by default. + pub game_tools: crate::platform::GameTools, } -/// Unset or unreadable values fall back to the defaults: every switch on, the language Windows'. +/// Unset or unreadable values fall back to the defaults: every switch on but the game tools, the language Windows'. pub fn load(conn: &Connection) -> Settings { let get = |name| db::setting(conn, name).ok().flatten(); Settings { @@ -75,6 +81,11 @@ pub fn load(conn: &Connection) -> Settings { language: get(LANGUAGE) .filter(|v| crate::msg::is_language(v)) .unwrap_or_else(|| "system".into()), + game_tools: crate::platform::GameTools { + gamescope: get(GAMESCOPE).is_some_and(|v| v == "true"), + mangohud: get(MANGOHUD).is_some_and(|v| v == "true"), + gamemode: get(GAMEMODE).is_some_and(|v| v == "true"), + }, } } @@ -82,7 +93,7 @@ pub fn load(conn: &Connection) -> Settings { pub fn validate(name: &str, value: Option<&str>) -> Result<(), Msg> { match name { SHOW_BANNER | AMBIENT | CLOUD_SAVES | GOG_CLOUD_SAVES | CLOSE_TO_TRAY - | NOTIFY_DOWNLOADS | START_WITH_WINDOWS => match value { + | NOTIFY_DOWNLOADS | START_WITH_WINDOWS | GAMESCOPE | MANGOHUD | GAMEMODE => match value { None | Some("true" | "false") => Ok(()), Some(_) => Err(msg!(settingNotBool, name = name)), }, diff --git a/src-tauri/src/wine.rs b/src-tauri/src/wine.rs index 8b5cc67..43cc260 100644 --- a/src-tauri/src/wine.rs +++ b/src-tauri/src/wine.rs @@ -13,6 +13,7 @@ use serde_json::Value; use sha2::{Sha256, Sha512}; use crate::cache::{Dirs, db}; +use crate::library::tool::LaunchOptions; use crate::msg::Msg; use crate::platform::{ProtonKind, ProtonView, ReleaseView, RunnerView}; use crate::tools::{Installing, download}; @@ -46,7 +47,7 @@ fn managed_umu(tools: &Path) -> PathBuf { tools.join("umu").join("umu").join("umu-run") } -fn on_path(name: &str) -> Option { +pub fn on_path(name: &str) -> Option { std::env::split_paths(&std::env::var_os("PATH")?) .map(|dir| dir.join(name)) .find(|p| p.is_file()) @@ -271,9 +272,10 @@ fn wrap(game: &Command, key: &str, proton: Option<&str>) -> Result<(Command, Pro /// A game's launch through `wrap`. When umu still has to fetch the Steam Linux Runtime or set the prefix up, the copy /// counts as setting up (`setting_up`) until the game's own program runs. -pub fn game_command(game: Command, key: &str, proton: Option<&str>) -> Result { +pub fn game_command(game: Command, key: &str, options: &LaunchOptions) -> Result { install_runner(key)?; - let (mut command, proton) = wrap(&game, key, proton)?; + let (command, proton) = wrap(&game, key, options.proton.as_deref())?; + let mut command = crate::game_tools::wrap(command, crate::game_tools::chosen(options)); match fs_err::File::create(crate::log::game_output(key)) { Ok(file) => _ = command.stderr(file.into_file()), Err(e) => tracing::warn!("game output: {e}"), @@ -531,6 +533,7 @@ pub fn view() -> RunnerView { RunnerView { umu: umu().is_some(), winetricks: on_path("winetricks").is_some() || protons.iter().any(bundles_winetricks), + tools: crate::game_tools::installed(), protons: protons .into_iter() .map(|p| ProtonView { diff --git a/src/lib/Detail.svelte b/src/lib/Detail.svelte index a2c5535..d547ec8 100644 --- a/src/lib/Detail.svelte +++ b/src/lib/Detail.svelte @@ -51,6 +51,7 @@ type Detail, type Dlc, type GameInfo, + type GameTools, type GamePrefix, type LaunchOptions, type LinkKind, @@ -305,6 +306,28 @@ } }) + /** Linux: the game tools installed; null on Windows. A game's choice is null (follows Settings), true or false. */ + let tools = $state(null) + onMount(() => { + commands.gameTools().then( + (found) => (tools = found), + () => {}, + ) + }) + type ToolId = keyof GameTools + const toolRows: { id: ToolId; name: string; hint: string }[] = [ + { id: 'gamescope', name: 'Gamescope', hint: 'settings.gamescopeHint' }, + { id: 'mangohud', name: 'MangoHud', hint: 'settings.mangohudHint' }, + { id: 'gamemode', name: 'GameMode', hint: 'settings.gamemodeHint' }, + ] + const toolChoices = $derived([ + { value: '', label: t('detail.default') }, + { value: 'on', label: t('common.on') }, + { value: 'off', label: t('common.off') }, + ]) + const toolChoice = (on: boolean | null | undefined) => (on == null ? '' : on ? 'on' : 'off') + let toolOpen = $state>({ gamescope: false, mangohud: false, gamemode: false }) + /** Linux: the Proton builds a game may pick, newest first; '' follows Settings. */ let protons = $state([]) const protonChoices = $derived([{ value: '', label: t('detail.default') }, ...protons.map((p) => ({ value: p, label: p }))]) @@ -497,8 +520,8 @@ const ids: Tab[] = ['overview'] if (dlcs.length) ids.push('dlc') if (copy?.cloudSaves) ids.push('saves') - // An added game's only launch option is its Proton build, so only on Linux. - if (copy?.installed && (!custom || protons.length)) ids.push('launch') + // An added game's only launch options are its Proton build and game tools, so only on Linux. + if (copy?.installed && (!custom || protons.length || tools)) ids.push('launch') if (copy?.installed || copy?.installDir) ids.push('installation') return ids.map((id) => ({ id, label: t(`detail.tab.${id}`), count: id === 'dlc' ? dlcs.length : undefined })) }) @@ -840,6 +863,33 @@ {/if} + {#if tools} + {#each toolRows as tool (tool.id)} + {@const label = toolChoices.find((c) => c.value === toolChoice(launch?.[tool.id]))?.label ?? ''} +
+
+ {tool.name}{tools[tool.id] ? t(tool.hint) : t('settings.toolMissing')} +
+
+ {#if tools[tool.id]} + toolChoice(launch?.[tool.id]), (v) => setLaunch({ [tool.id]: v === '' ? null : v === 'on' })} + options={toolChoices} + label={tool.name} + bind:open={toolOpen[tool.id]} + > + {#snippet trigger({ props })} + + {/snippet} + + {:else} + + {/if} +
+
+ {/each} + {/if} {/if} {:else if current === 'installation'} diff --git a/src/lib/Settings.svelte b/src/lib/Settings.svelte index 1081a89..3ad53be 100644 --- a/src/lib/Settings.svelte +++ b/src/lib/Settings.svelte @@ -652,8 +652,8 @@ {@render icon(name)} {/snippet} -{#snippet toggleButton(on: boolean, labelId: string, onchange: (on: boolean) => void)} - +{#snippet toggleButton(on: boolean, labelId: string, onchange: (on: boolean) => void, disabled = false)} + {#snippet child({ props })} {/snippet} @@ -670,6 +670,17 @@ {/snippet} +{#snippet toolRow(setting: string, field: SwitchField, name: string, hint: string, installed: boolean, extension?: string)} +
+
+ {name} + {#if installed}{hint} + {:else}{view.flatpak && extension ? t('settings.toolMissingFlatpak', { extension }) : t('settings.toolMissing')}{/if} +
+ {@render toggleButton(installed && view[field], `${setting}-label`, (v) => toggle(setting, field, v), !installed)} +
+{/snippet} + {#snippet chevron()} {/snippet} @@ -1231,6 +1242,28 @@ +

{t('settings.group.gameTools')}

+
+ {@render toolRow( + 'gamescope', + 'useGamescope', + 'Gamescope', + t('settings.gamescopeHint'), + runner.tools.gamescope, + 'org.freedesktop.Platform.VulkanLayer.gamescope', + )} + {@render toolRow( + 'mangohud', + 'useMangohud', + 'MangoHud', + t('settings.mangohudHint'), + runner.tools.mangohud, + 'org.freedesktop.Platform.VulkanLayer.MangoHud', + )} + {@render toolRow('gamemode', 'useGamemode', 'GameMode', t('settings.gamemodeHint'), runner.tools.gamemode)} +

{t('settings.protonForHint')}

+
+

{t('settings.group.protonBuilds')}

{#each runner.protons as p (p.name)} diff --git a/src/lib/bindings.ts b/src/lib/bindings.ts index c021156..9f10ef0 100644 --- a/src/lib/bindings.ts +++ b/src/lib/bindings.ts @@ -123,6 +123,8 @@ export const commands = { syncSavesNow: (key: string) => __TAURI_INVOKE("sync_saves_now", { key }), /** The Launch options tab of an installed Epic, GOG or Amazon copy; `None` for others. */ launchOptions: (key: string) => __TAURI_INVOKE("launch_options", { key }), + /** Linux: the game tools installed, for a game's Launch options; `None` on Windows. */ + gameTools: () => __TAURI_INVOKE("game_tools"), /** * Saves an installed Epic, GOG or Amazon copy's launch options. `exe` may be absolute (from the file picker); it is * stored relative to the install folder, and only when it is a file inside it. Returns what was stored. @@ -438,6 +440,13 @@ export type GamePrefix = { winetricks: boolean, }; +/** Linux: gamescope, MangoHud and GameMode, as chosen in Settings, as installed, or as a game runs with. */ +export type GameTools = { + gamescope: boolean, + mangohud: boolean, + gamemode: boolean, +}; + export type GridCover = { /** The full image, passed back to `save_custom_game`. */ url: string, @@ -499,6 +508,10 @@ export type LaunchOptions = { exe?: string | null, /** Linux: the Proton build this game runs with, by folder name; none follows Settings. */ proton?: string | null, + /** Linux: whether it runs in gamescope, with MangoHud, with GameMode; none follows Settings. */ + gamescope?: boolean | null, + mangohud?: boolean | null, + gamemode?: boolean | null, }; export type Library = { @@ -635,6 +648,8 @@ export type RunnerView = { protons: ProtonView[], proton: string | null, winetricks: boolean, + /** The game tools installed (`GameTools`). */ + tools: GameTools, }; export type SavesView = { @@ -692,6 +707,10 @@ export type SettingsView = { linux: boolean, /** A Flatpak hides update checks. */ flatpak: boolean, + /** Linux: gamescope, MangoHud and GameMode for every game unless its launch options say otherwise. */ + useGamescope: boolean, + useMangohud: boolean, + useGamemode: boolean, closeToTray: boolean, notifyDownloads: boolean, appVersion: string, diff --git a/src/lib/i18n/en.json b/src/lib/i18n/en.json index 31b110b..e1c3e51 100644 --- a/src/lib/i18n/en.json +++ b/src/lib/i18n/en.json @@ -570,6 +570,7 @@ "settings.proton": "Proton", "settings.protonMissing": "None found", "detail.protonHint": "Windows games run through it", + "detail.toolNow": "{tool}: {choice}", "settings.section.wine": "Wine", "settings.group.prefixes": "Prefixes", "settings.removing": "Removing…", @@ -592,6 +593,12 @@ "settings.protonForHint": "A game's own choice in Launch options comes first", "settings.protonNewest": "Newest ({name})", "settings.group.protonBuilds": "Proton builds", + "settings.group.gameTools": "Game tools", + "settings.gamescopeHint": "Runs the game fullscreen in its own compositor", + "settings.mangohudHint": "Shows frame rate and load over the game", + "settings.gamemodeHint": "Asks the system for full performance while you play", + "settings.toolMissing": "Not installed", + "settings.toolMissingFlatpak": "Install {extension} from Flathub", "settings.inUse": "in use", "settings.installAnother": "Install another build", "settings.show": "Show", diff --git a/src/lib/i18n/nl.json b/src/lib/i18n/nl.json index 50acec5..39c328d 100644 --- a/src/lib/i18n/nl.json +++ b/src/lib/i18n/nl.json @@ -570,6 +570,7 @@ "settings.proton": "Proton", "settings.protonMissing": "Geen gevonden", "detail.protonHint": "Windows-games draaien ermee", + "detail.toolNow": "{tool}: {choice}", "settings.section.wine": "Wine", "settings.group.prefixes": "Prefixes", "settings.removing": "Verwijderen…", @@ -592,6 +593,12 @@ "settings.protonForHint": "De eigen keuze van een game onder Startopties gaat voor", "settings.protonNewest": "Nieuwste ({name})", "settings.group.protonBuilds": "Proton-versies", + "settings.group.gameTools": "Gametools", + "settings.gamescopeHint": "Draait de game schermvullend in een eigen compositor", + "settings.mangohudHint": "Toont framerate en belasting over de game", + "settings.gamemodeHint": "Vraagt het systeem om volle prestaties terwijl je speelt", + "settings.toolMissing": "Niet geïnstalleerd", + "settings.toolMissingFlatpak": "Installeer {extension} van Flathub", "settings.inUse": "in gebruik", "settings.installAnother": "Andere versie installeren", "settings.show": "Tonen", From 045465e45567a4d3adabaa523fbc14b88ee7daa5 Mon Sep 17 00:00:00 2001 From: TheBiemGamer <47662596+TheBiemGamer@users.noreply.github.com> Date: Mon, 16 Nov 2026 13:43:55 +0000 Subject: [PATCH 4/4] feat(linux): apply Heroic's known fixes to Epic, GOG and Amazon games The community list's environment variables for a game, matched by the store's own id, are set before it runs through umu. The list is cached in info (kind known-fixes) for a day and refreshed behind a Play once stale; a variable the launch or Guild's own environment already sets wins. Its winetricks verbs and installers are left out. --- DEVELOPMENT.md | 2 +- src-tauri/src/known_fixes.rs | 146 +++++++++++++++++++++++++++++++++++ src-tauri/src/main.rs | 2 + src-tauri/src/wine.rs | 10 ++- 4 files changed, 157 insertions(+), 3 deletions(-) create mode 100644 src-tauri/src/known_fixes.rs diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index c8b4c95..3bc79c4 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -10,7 +10,7 @@ You need [Node.js](https://nodejs.org) 24 or later, [Rust](https://rustup.rs) st sudo apt install libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev libxdo-dev libssl-dev patchelf build-essential ``` -On Arch: `webkit2gtk-4.1 libayatana-appindicator librsvg xdotool base-devel`. At runtime Linux also needs `python3` (the Linux builds of Legendary and gogdl run on it), `xdg-open`, and a Secret Service provider such as GNOME Keyring or KWallet for the saved secrets. Windows games run through `umu-run` (from PATH, or downloaded in Settings or by the first Play that needs it) and a Proton build: GE-Proton in Steam's `compatibilitytools.d`, Steam's own Proton, or GE-Proton and Proton-CachyOS installed from Settings → Wine; with none, Play installs the newest GE-Proton. Gamescope, MangoHud and GameMode (`gamescope`, `mangohud`, `gamemoderun` on PATH) wrap Windows and native games when switched on in Settings → Wine or a game's Launch options. Each game gets its own Wine prefix under `/prefixes/`; uninstalling a game keeps it unless the owner ticks the option to remove it, since its saves live there. Settings → Wine lists and removes prefixes. The pinned umu-launcher version and hash are in `src-tauri/src/wine.rs`. +On Arch: `webkit2gtk-4.1 libayatana-appindicator librsvg xdotool base-devel`. At runtime Linux also needs `python3` (the Linux builds of Legendary and gogdl run on it), `xdg-open`, and a Secret Service provider such as GNOME Keyring or KWallet for the saved secrets. Windows games run through `umu-run` (from PATH, or downloaded in Settings or by the first Play that needs it) and a Proton build: GE-Proton in Steam's `compatibilitytools.d`, Steam's own Proton, or GE-Proton and Proton-CachyOS installed from Settings → Wine; with none, Play installs the newest GE-Proton. Gamescope, MangoHud and GameMode (`gamescope`, `mangohud`, `gamemoderun` on PATH) wrap Windows and native games when switched on in Settings → Wine or a game's Launch options. Epic, GOG and Amazon Windows games also get the environment variables Heroic's [known fixes](https://github.com/Heroic-Games-Launcher/known-fixes) list for them (by store id, cached for a day; not its winetricks verbs). Each game gets its own Wine prefix under `/prefixes/`; uninstalling a game keeps it unless the owner ticks the option to remove it, since its saves live there. Settings → Wine lists and removes prefixes. The pinned umu-launcher version and hash are in `src-tauri/src/wine.rs`. ```bash npm install diff --git a/src-tauri/src/known_fixes.rs b/src-tauri/src/known_fixes.rs new file mode 100644 index 0000000..771cbb1 --- /dev/null +++ b/src-tauri/src/known_fixes.rs @@ -0,0 +1,146 @@ +//! Heroic's community known fixes (github.com/Heroic-Games-Launcher/known-fixes): per-game environment variables for +//! Epic, GOG and Amazon Windows games, matched by the store's own id. Only the variables are applied; the winetricks +//! verbs and installers it also lists would mean long downloads inside a Play, and umu's protonfixes already cover +//! many of those games. + +use std::sync::atomic::{AtomicBool, Ordering}; +use std::time::Duration; + +use serde_json::Value; + +use crate::cache::{Dirs, db}; + +const URL: &str = + "https://raw.githubusercontent.com/Heroic-Games-Launcher/known-fixes/main/known_fixes.json"; +/// `info` key and kind of the fixes, as fetched: `{"": {"": {"envVariables": {…}, …}}}`. +const KIND: &str = "known-fixes"; +const MAX_AGE_SECS: i64 = 24 * 60 * 60; + +/// The variables the fixes list for the copy `key`, never one Guild was started with: the player's own environment +/// wins. A Play without the list fetches it first (5 s at most); a stale list is used and refreshed behind it. +// shortcut: offline, a Play without the list tries again each time (5 s at most), like umu's database in `wine`. +pub fn env(key: &str) -> Vec<(String, String)> { + let Ok(conn) = db::open(&Dirs::new().db) else { + return Vec::new(); + }; + let now = crate::library::unix_now(); + let fresh = db::cached_info(&conn, KIND, KIND, MAX_AGE_SECS, now) + .ok() + .flatten(); + let json = match fresh { + Some(json) => Some(json), + None => match db::cached_info(&conn, KIND, KIND, i64::MAX, now) + .ok() + .flatten() + { + Some(stale) => { + refresh_behind(); + Some(stale) + } + None => fetch().inspect(|json| _ = db::put_info(&conn, KIND, KIND, json, now)), + }, + }; + let fixes = json.and_then(|j| serde_json::from_str::(&j).ok()); + fixes + .map(|f| variables(&f, key)) + .unwrap_or_default() + .into_iter() + .filter(|(name, _)| std::env::var_os(name).is_none()) + .collect() +} + +/// The `envVariables` of the copy `key` (`epic-`, `gog-`, `amazon-`), as text. +fn variables(fixes: &Value, key: &str) -> Vec<(String, String)> { + let Some((store, id)) = key.split_once('-') else { + return Vec::new(); + }; + let Some(Value::Object(vars)) = fixes + .get(store) + .and_then(|s| s.get(id)?.get("envVariables")) + else { + return Vec::new(); + }; + vars.iter() + .filter_map(|(name, value)| { + let text = match value { + Value::String(s) => s.clone(), + // As Heroic, whose launches these were tested with, passes them. + Value::Bool(b) => b.to_string(), + Value::Number(n) => n.to_string(), + _ => return None, + }; + Some((name.clone(), text)) + }) + .collect() +} + +/// Refreshes the cached list on its own thread, one refresh at a time. +fn refresh_behind() { + static RUNNING: AtomicBool = AtomicBool::new(false); + if RUNNING.swap(true, Ordering::SeqCst) { + return; + } + let spawned = std::thread::Builder::new() + .name("known-fixes".into()) + .spawn(|| { + if let (Some(json), Ok(conn)) = (fetch(), db::open(&Dirs::new().db)) { + _ = db::put_info(&conn, KIND, KIND, &json, crate::library::unix_now()); + } + RUNNING.store(false, Ordering::SeqCst); + }); + if spawned.is_err() { + RUNNING.store(false, Ordering::SeqCst); + } +} + +fn fetch() -> Option { + let text = tauri::async_runtime::block_on(async { + crate::wine::http() + .get(URL) + .timeout(Duration::from_secs(5)) + .send() + .await? + .error_for_status()? + .text() + .await + }) + .inspect_err(|e| tracing::warn!("known fixes: {e}")) + .ok()?; + // Only a list that parses is cached. + serde_json::from_str::(&text).ok().map(|_| text) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn matches_by_store_and_id_with_values_as_text() { + let fixes = serde_json::json!({ + "epic": { + "Heather": { "title": "x", "envVariables": { "USE_FAKE_EPIC_EXE": true } }, + "Fortnite": { "envVariables": { "USE_FAKE_EPIC_EXE": "0", "N": 2 } }, + "Sugar": { "winetricks": ["vcrun2022"] } + }, + "gog": { "1207658924": { "envVariables": { "A": "b" } } } + }); + assert_eq!( + variables(&fixes, "epic-Heather"), + [("USE_FAKE_EPIC_EXE".into(), "true".into())] + ); + assert_eq!( + variables(&fixes, "epic-Fortnite"), + [ + ("N".into(), "2".into()), + ("USE_FAKE_EPIC_EXE".into(), "0".into()) + ] + ); + assert!(variables(&fixes, "epic-Sugar").is_empty()); + assert!(variables(&fixes, "gog-Heather").is_empty()); + assert_eq!( + variables(&fixes, "gog-1207658924"), + [("A".into(), "b".into())] + ); + assert!(variables(&fixes, "custom-1").is_empty()); + } +} diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index a6f089d..3c48850 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -18,6 +18,8 @@ mod gamesdb; mod gog_login; mod igdb; mod info; +#[cfg(target_os = "linux")] +mod known_fixes; mod library; mod links; mod log; diff --git a/src-tauri/src/wine.rs b/src-tauri/src/wine.rs index 43cc260..2c6cb42 100644 --- a/src-tauri/src/wine.rs +++ b/src-tauri/src/wine.rs @@ -32,7 +32,7 @@ const UMU_IDS_MAX_AGE_SECS: i64 = 7 * 24 * 60 * 60; const DOWNLOAD_TIMEOUT: Duration = Duration::from_secs(2 * 60 * 60); /// GitHub's API refuses requests without a User-Agent. -fn http() -> &'static reqwest::Client { +pub fn http() -> &'static reqwest::Client { static HTTP: LazyLock = LazyLock::new(|| { reqwest::Client::builder() .timeout(Duration::from_secs(15)) @@ -272,8 +272,14 @@ fn wrap(game: &Command, key: &str, proton: Option<&str>) -> Result<(Command, Pro /// A game's launch through `wrap`. When umu still has to fetch the Steam Linux Runtime or set the prefix up, the copy /// counts as setting up (`setting_up`) until the game's own program runs. -pub fn game_command(game: Command, key: &str, options: &LaunchOptions) -> Result { +pub fn game_command(mut game: Command, key: &str, options: &LaunchOptions) -> Result { install_runner(key)?; + // A variable the store tool or the game's own options already set wins over a known fix. + for (name, value) in crate::known_fixes::env(key) { + if !game.get_envs().any(|(set, _)| set == name.as_str()) { + game.env(name, value); + } + } let (command, proton) = wrap(&game, key, options.proton.as_deref())?; let mut command = crate::game_tools::wrap(command, crate::game_tools::chosen(options)); match fs_err::File::create(crate::log::game_output(key)) {