Skip to content

Commit 0aebb69

Browse files
committed
Revert Lutris change when "installed" is true
1 parent aba6c7f commit 0aebb69

File tree

3 files changed

+32
-26
lines changed

3 files changed

+32
-26
lines changed

src/platforms/lutris/game_list_parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@ mod tests {
6262

6363
let games = parse_lutris_games(content);
6464

65-
assert_eq!(games[1].service, "steam");
65+
assert_eq!(games[1].service.clone().unwrap_or_default(), "steam");
6666
}
6767
}

src/platforms/lutris/lutris_game.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ pub struct LutrisGame {
99
pub id: i64,
1010
pub slug: String,
1111
pub name: String,
12-
pub service: String,
12+
pub service: Option<String>,
13+
pub runner:Option<String>,
1314
pub installed: bool,
1415
pub details: String,
1516
pub settings: Option<LutrisSettings>,
@@ -39,17 +40,25 @@ impl LutrisGame {
3940
.as_ref()
4041
.map(|s| s.flatpak)
4142
.unwrap_or_default();
43+
let run_game = self
44+
.settings
45+
.as_ref()
46+
.map(|s| s.installed)
47+
.map(|i| if i { ":rungame/" } else { ":" })
48+
.unwrap_or_default();
49+
4250
if is_flatpak {
4351
format!(
44-
"run {} lutris:{}",
52+
"run {} lutris{}{}",
4553
self.settings
4654
.as_ref()
4755
.map(|s| s.flatpak_image.clone())
4856
.unwrap_or_default(),
57+
run_game,
4958
self.slug
5059
)
5160
} else {
52-
format!("lutris:{}", self.slug)
61+
format!("lutris{}{}", run_game, self.slug)
5362
}
5463
}
5564

src/platforms/lutris/lutris_platform.rs

+19-22
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ impl LutrisPlatform {
1515
fn get_shortcuts(&self) -> eyre::Result<Vec<LutrisGame>> {
1616
let output = get_lutris_command_output(&self.settings)?;
1717
let games = parse_lutris_games(output.as_str());
18+
let installed = self.settings.installed;
1819
let mut res = vec![];
1920
for mut game in games {
20-
if game.service != "steam" {
21+
let service = if installed { game.runner.clone().unwrap_or_default() } else { game.service.clone().unwrap_or_default() };
22+
if service != "steam" {
2123
game.settings = Some(self.settings.clone());
2224
res.push(game);
2325
}
@@ -32,16 +34,12 @@ fn get_lutris_command_output(settings: &LutrisSettings) -> eyre::Result<String>
3234
#[cfg(not(feature = "flatpak"))]
3335
{
3436
let mut command = Command::new("flatpak");
35-
command
36-
.arg("run")
37-
.arg(flatpak_image)
38-
.arg("-a")
39-
.arg("--json");
40-
if settings.installed {
41-
command.arg("-o").output()?
42-
} else {
43-
command.output()?
44-
}
37+
command.arg("run").arg(flatpak_image).arg("--json");
38+
if settings.installed {
39+
command.arg("-lo").output()?
40+
} else {
41+
command.arg("-a").output()?
42+
}
4543
}
4644
#[cfg(feature = "flatpak")]
4745
{
@@ -50,22 +48,21 @@ fn get_lutris_command_output(settings: &LutrisSettings) -> eyre::Result<String>
5048
.arg("--host")
5149
.arg("flatpak")
5250
.arg("run")
53-
.arg(flatpak_image)
54-
.arg("-a")
55-
.arg("--json");
56-
if settings.installed {
57-
command.arg("-o").output()?
58-
} else {
59-
command.output()?
60-
}
51+
.arg(flatpak_image);
52+
command.arg("run").arg(flatpak_image).arg("--json");
53+
if settings.installed {
54+
command.arg("-lo").output()?
55+
} else {
56+
command.arg("-a").output()?
57+
}
6158
}
6259
} else {
6360
let mut command = Command::new(&settings.executable);
64-
command.arg("-a").arg("--json");
61+
command.arg("--json");
6562
if settings.installed {
66-
command.arg("-o").output()?
63+
command.arg("-lo").output()?
6764
} else {
68-
command.output()?
65+
command.arg("-a").output()?
6966
}
7067
};
7168

0 commit comments

Comments
 (0)