From 2a5e7711c5d8451d2d67917b3da351a245702fe5 Mon Sep 17 00:00:00 2001 From: ALEZ-DEV Date: Wed, 9 Oct 2024 21:13:09 +0200 Subject: [PATCH] workaround for flatpak version of steam #12 --- .../src/components/proton_component.rs | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/babylonia-terminal-sdk/src/components/proton_component.rs b/babylonia-terminal-sdk/src/components/proton_component.rs index 8662cfc..c628e47 100644 --- a/babylonia-terminal-sdk/src/components/proton_component.rs +++ b/babylonia-terminal-sdk/src/components/proton_component.rs @@ -106,16 +106,31 @@ impl ProtonComponent { pub fn init_proton(&self) -> Result { let prefix = self.path.parent().unwrap().join("data"); - let steam_location = dirs::home_dir().unwrap().join(".steam/steam"); - if !steam_location.exists() { - debug!("Can't find steam installation"); - return Err(String::from_str("We can't find your steam installation, please install steam in '~/.steam/steam' or specify your steam installation").unwrap()); - } + let mut proton = wincompatlib::prelude::Proton::new(self.path.clone(), Some(prefix.clone())); + let steam_location = Self::get_steam_location()?; proton.steam_client_path = Some(steam_location); proton.init_prefix(Some(prefix)).unwrap(); Ok(proton) } + + fn get_steam_location() -> Result { + let location_to_check = [ + dirs::home_dir().unwrap().join(".steam/steam"), + dirs::home_dir() + .unwrap() + .join("/.var/app/com.valvesoftware.Steam/steam"), // for the flatpak version of steam + ]; + + for location in location_to_check { + if location.exists() { + return Ok(location); + } + } + + debug!("Can't find steam installation"); + Err(String::from_str("We can't find your steam installation, please install steam in '~/.steam/steam' or specify your steam installation").unwrap()) + } }