From a78064377d90335cf5c10ab6ddf6942e842aab59 Mon Sep 17 00:00:00 2001 From: Santiago Fisela Date: Sat, 11 Apr 2026 17:19:14 -0300 Subject: [PATCH] Reapply "Hope this doesn't break appimages on gentoo + steam deck test" This reverts commit a7577bbd7258c5b6fc6eb9b32c585f9f8b55b19d. --- src-tauri/src/lib.rs | 13 ++++++++++--- src-tauri/src/main.rs | 29 +++++++++++++++++++---------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 0f5933a..3a93bd8 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1051,9 +1051,13 @@ async fn launch_game(app: AppHandle, state: State<'_, GameState>, instance_id: S let mut c = tokio::process::Command::new(proton_exe); let compat_data = instance_dir.join("proton_prefix"); fs::create_dir_all(&compat_data).map_err(|e| e.to_string())?; - c.env("STEAM_COMPAT_CLIENT_INSTALL_PATH", ""); + if std::env::var("STEAM_COMPAT_CLIENT_INSTALL_PATH").is_err() { + c.env("STEAM_COMPAT_CLIENT_INSTALL_PATH", ""); + } c.env("STEAM_COMPAT_DATA_PATH", compat_data.to_str().unwrap()); - c.env("SteamAppId", "480"); + if std::env::var("SteamAppId").is_err() { + c.env("SteamAppId", "480"); + } c.arg("run"); c } else { @@ -1061,7 +1065,10 @@ async fn launch_game(app: AppHandle, state: State<'_, GameState>, instance_id: S }; #[cfg(unix)] - cmd.process_group(0); + { + cmd.process_group(0); + cmd.env_remove("LD_PRELOAD"); + } cmd.arg(&game_exe) .current_dir(&instance_dir); diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 868cbaa..a00ae0a 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -10,9 +10,15 @@ fn main() { use std::thread; let stage = env::var("EMERALD_LAUNCH_STAGE").unwrap_or_else(|_| "0".to_string()); if stage == "0" { - let mut child = Command::new(env::current_exe().unwrap()) - .env("EMERALD_LAUNCH_STAGE", "1") - .env("LD_PRELOAD", "LD_PRELOAD=/usr/lib64/libwayland-client.so.0") //neo: hacky way to fix appimage on systems like gentoo + let mut cmd = Command::new(env::current_exe().unwrap()); + cmd.env("EMERALD_LAUNCH_STAGE", "1"); + + let wayland_libs = ["/usr/lib/libwayland-client.so.0", "/usr/lib64/libwayland-client.so.0"]; + if let Some(path) = wayland_libs.iter().find(|p| std::path::Path::new(p).exists()) { + cmd.env("LD_PRELOAD", path); + } + + let mut child = cmd .stdout(Stdio::piped()) .stderr(Stdio::piped()) .spawn() @@ -69,14 +75,17 @@ fn main() { if found_error { println!("Emerald: Automatic recovery triggered for graphics crash/invisible launch."); } - - let mut retry_child = Command::new(env::current_exe().unwrap()) - .env("EMERALD_LAUNCH_STAGE", "2") + let mut retry_cmd = Command::new(env::current_exe().unwrap()); + retry_cmd.env("EMERALD_LAUNCH_STAGE", "2") + .env("GDK_BACKEND", "x11") .env("WEBKIT_DISABLE_DMABUF_RENDERER", "1") - .env("WEBKIT_DISABLE_COMPOSITING_MODE", "1") - .env("LD_PRELOAD", "LD_PRELOAD=/usr/lib64/libwayland-client.so.0") //neo: hacky way to fix appimage on systems like gentoo - .spawn() - .expect("failed to spawn fallback child process"); + .env("WEBKIT_DISABLE_COMPOSITING_MODE", "1"); + + if let Some(path) = wayland_libs.iter().find(|p| std::path::Path::new(p).exists()) { + retry_cmd.env("LD_PRELOAD", path); + } + + let mut retry_child = retry_cmd.spawn().expect("failed to spawn fallback child process"); let retry_status = retry_child.wait().expect("failed to wait on fallback child process"); exit(retry_status.code().unwrap_or(1));