Reapply "Hope this doesn't break appimages on gentoo + steam deck test"

This reverts commit a7577bbd72.
This commit is contained in:
Santiago Fisela
2026-04-11 17:19:14 -03:00
parent a7577bbd72
commit a78064377d
2 changed files with 29 additions and 13 deletions

View File

@@ -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);

View File

@@ -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));