From 0aebb690d2ecae3ee61566f2f0e9ffbf05bf421e Mon Sep 17 00:00:00 2001 From: Philip Kristoffersen Date: Tue, 19 Sep 2023 22:36:45 +0200 Subject: [PATCH] Revert Lutris change when "installed" is true --- src/platforms/lutris/game_list_parser.rs | 2 +- src/platforms/lutris/lutris_game.rs | 15 +++++++-- src/platforms/lutris/lutris_platform.rs | 41 +++++++++++------------- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/src/platforms/lutris/game_list_parser.rs b/src/platforms/lutris/game_list_parser.rs index fe43d96..b1a66d4 100644 --- a/src/platforms/lutris/game_list_parser.rs +++ b/src/platforms/lutris/game_list_parser.rs @@ -62,6 +62,6 @@ mod tests { let games = parse_lutris_games(content); - assert_eq!(games[1].service, "steam"); + assert_eq!(games[1].service.clone().unwrap_or_default(), "steam"); } } diff --git a/src/platforms/lutris/lutris_game.rs b/src/platforms/lutris/lutris_game.rs index 6d812f6..19641e5 100644 --- a/src/platforms/lutris/lutris_game.rs +++ b/src/platforms/lutris/lutris_game.rs @@ -9,7 +9,8 @@ pub struct LutrisGame { pub id: i64, pub slug: String, pub name: String, - pub service: String, + pub service: Option, + pub runner:Option, pub installed: bool, pub details: String, pub settings: Option, @@ -39,17 +40,25 @@ impl LutrisGame { .as_ref() .map(|s| s.flatpak) .unwrap_or_default(); + let run_game = self + .settings + .as_ref() + .map(|s| s.installed) + .map(|i| if i { ":rungame/" } else { ":" }) + .unwrap_or_default(); + if is_flatpak { format!( - "run {} lutris:{}", + "run {} lutris{}{}", self.settings .as_ref() .map(|s| s.flatpak_image.clone()) .unwrap_or_default(), + run_game, self.slug ) } else { - format!("lutris:{}", self.slug) + format!("lutris{}{}", run_game, self.slug) } } diff --git a/src/platforms/lutris/lutris_platform.rs b/src/platforms/lutris/lutris_platform.rs index 5a23ef9..e504b09 100644 --- a/src/platforms/lutris/lutris_platform.rs +++ b/src/platforms/lutris/lutris_platform.rs @@ -15,9 +15,11 @@ impl LutrisPlatform { fn get_shortcuts(&self) -> eyre::Result> { let output = get_lutris_command_output(&self.settings)?; let games = parse_lutris_games(output.as_str()); + let installed = self.settings.installed; let mut res = vec![]; for mut game in games { - if game.service != "steam" { + let service = if installed { game.runner.clone().unwrap_or_default() } else { game.service.clone().unwrap_or_default() }; + if service != "steam" { game.settings = Some(self.settings.clone()); res.push(game); } @@ -32,16 +34,12 @@ fn get_lutris_command_output(settings: &LutrisSettings) -> eyre::Result #[cfg(not(feature = "flatpak"))] { let mut command = Command::new("flatpak"); - command - .arg("run") - .arg(flatpak_image) - .arg("-a") - .arg("--json"); - if settings.installed { - command.arg("-o").output()? - } else { - command.output()? - } + command.arg("run").arg(flatpak_image).arg("--json"); + if settings.installed { + command.arg("-lo").output()? + } else { + command.arg("-a").output()? + } } #[cfg(feature = "flatpak")] { @@ -50,22 +48,21 @@ fn get_lutris_command_output(settings: &LutrisSettings) -> eyre::Result .arg("--host") .arg("flatpak") .arg("run") - .arg(flatpak_image) - .arg("-a") - .arg("--json"); - if settings.installed { - command.arg("-o").output()? - } else { - command.output()? - } + .arg(flatpak_image); + command.arg("run").arg(flatpak_image).arg("--json"); + if settings.installed { + command.arg("-lo").output()? + } else { + command.arg("-a").output()? + } } } else { let mut command = Command::new(&settings.executable); - command.arg("-a").arg("--json"); + command.arg("--json"); if settings.installed { - command.arg("-o").output()? + command.arg("-lo").output()? } else { - command.output()? + command.arg("-a").output()? } };