Heroic: Play starts Epic and GOG games through Heroic (heroic://launch), and the Flatpak Heroic's games are found

Entries get launch_uri (serde default, so cached data still loads); Heroic's keeps the exact, case-sensitive app
name (the id stays lowercased, so profiles and stats keep their keys). Play runs
summit run <id> --detached -- xdg-open 'heroic://launch?appName=..&runner=legendary|gog'. No Enhance for Heroic yet.
The URL format is from Heroic's src/backend/protocol.ts. Checked: unit tests and summit scan on a fake Flatpak
config; not run with a real Heroic.
This commit is contained in:
alex committed 2026-11-24 15:53:43 +00:00
1 parent fc838b95e9
commit 181cf5919c
7 files changed
+73 -15

No files matched your search

+45 -5
View File
@@ -3,13 +3,30 @@ use crate::model::{Entry, Kind, Source};
use serde_json::Value;
pub fn heroic() -> Vec<Entry> {
let mut roots = vec![];
if let Some(cfg) = dirs::config_dir() { roots.push(cfg.join("heroic")); }
if let Some(home) = dirs::home_dir() { roots.push(home.join(".var/app/com.heroicgameslauncher.hgl/config/heroic")); } // Flatpak
let mut out: Vec<Entry> = vec![];
for root in roots {
for e in heroic_in(&root) { if !out.iter().any(|o| o.id == e.id) { out.push(e); } }
}
out
}
/// Heroic's `heroic://` launch URL: Heroic starts the game itself (its Wine/Proton, its playtime).
pub fn heroic_uri(runner: &str, app_name: &str) -> String {
let enc: String = app_name.bytes().map(|b| if b.is_ascii_alphanumeric() || b"-_.~".contains(&b) { (b as char).to_string() } else { format!("%{b:02X}") }).collect();
format!("heroic://launch?appName={enc}&runner={runner}")
}
/// The installed Epic and GOG games of one Heroic config folder (`~/.config/heroic` or the Flatpak's).
pub fn heroic_in(root: &std::path::Path) -> Vec<Entry> {
let mut out = Vec::new();
let Some(cfg) = dirs::config_dir() else { return out };
let files = [
("Epic", cfg.join("heroic/legendaryConfig/legendary/installed.json")),
("GOG", cfg.join("heroic/gog_store/installed.json")),
("Epic", "legendary", root.join("legendaryConfig/legendary/installed.json")),
("GOG", "gog", root.join("gog_store/installed.json")),
];
for (store, f) in files {
for (store, runner, f) in files {
let Ok(txt) = std::fs::read_to_string(&f) else { continue };
let Ok(v) = serde_json::from_str::<Value>(&txt) else { continue };
// legendary: { appName: {title, install_path} }; gog: { installed: [ {appName, install_path} ] }
@@ -27,11 +44,13 @@ pub fn heroic() -> Vec<Entry> {
}
}
for (id, title, path) in items {
if id.is_empty() { continue; }
out.push(Entry {
id: format!("heroic:{store}:{id}").to_lowercase(), title, source: Source::Heroic, kind: Kind::Game,
installed: true, path: if path.is_empty() { None } else { Some(path) },
steam_app_id: None, playtime_minutes: 0, last_played: None,
reasons: vec![format!("listed as installed in Heroic {store} store ({})", f.display())],
launch_uri: Some(heroic_uri(runner, &id)),
});
}
}
@@ -54,8 +73,29 @@ pub fn lutris() -> Vec<Entry> {
out.push(Entry {
id: format!("lutris:{slug}"), title: slug.replace('-', " "), source: Source::Lutris, kind: Kind::Game,
installed: true, path: exe, steam_app_id: None, playtime_minutes: 0, last_played: None,
reasons: vec![format!("Lutris game config {} (runner: {runner})", p.display())],
launch_uri: None, reasons: vec![format!("Lutris game config {} (runner: {runner})", p.display())],
});
}
out
}
#[cfg(test)]
mod tests {
#[test]
fn heroic_keeps_the_app_name_for_its_launch_url() {
let d = std::env::temp_dir().join(format!("summit-heroic-{}", std::process::id()));
std::fs::create_dir_all(d.join("legendaryConfig/legendary")).unwrap();
std::fs::create_dir_all(d.join("gog_store")).unwrap();
std::fs::write(d.join("legendaryConfig/legendary/installed.json"), r#"{"Quail": {"title": "Celeste & Co", "install_path": "/g/q"}}"#).unwrap();
std::fs::write(d.join("gog_store/installed.json"), r#"{"installed": [{"appName": "1207658924", "install_path": "/g/w"}, {"install_path": "/g/none"}]}"#).unwrap();
let mut es = super::heroic_in(&d);
es.sort_by(|a, b| a.id.cmp(&b.id));
let got: Vec<_> = es.iter().map(|e| (e.id.as_str(), e.launch_uri.as_deref().unwrap())).collect();
assert_eq!(got, vec![
("heroic:epic:quail", "heroic://launch?appName=Quail&runner=legendary"),
("heroic:gog:1207658924", "heroic://launch?appName=1207658924&runner=gog"),
]);
assert_eq!(super::heroic_uri("legendary", "a b&c"), "heroic://launch?appName=a%20b%26c&runner=legendary");
let _ = std::fs::remove_dir_all(d);
}
}
+17 -3
View File
@@ -21,7 +21,9 @@ pub enum Plan {
/// * Added by hand: `summit run <id> [--enhance] -- <path>`: profile applied, session tracked.
/// * Lutris: `summit run <id> --detached -- lutris lutris:rungame/<slug>` (no enhance: Lutris games have no
/// window rule Summit can know in advance).
/// * Heroic and folders found on disk: not wired yet.
/// * Heroic: `summit run <id> --detached -- xdg-open heroic://launch?appName=..&runner=..`: Heroic starts the game
/// with its own Wine/Proton settings and keeps the playtime. No enhance yet (no window rule known in advance).
/// * Folders found on disk: not wired (add them with `summit add`).
pub fn plan(e: &Entry, summit_cli: Option<&Path>, enhance: bool) -> Plan {
let cli = summit_cli.map(|c| c.to_string_lossy().into_owned());
let via_run = |cli: &str, extra: &[String], cmd: Vec<String>| {
@@ -68,7 +70,14 @@ pub fn plan(e: &Entry, summit_cli: Option<&Path>, enhance: bool) -> Plan {
}
_ => Plan::Unsupported("no Lutris slug for this entry".into()),
},
Source::Heroic => Plan::Unsupported("launching Heroic games from Summit is not built yet".into()),
Source::Heroic => match e.launch_uri.as_deref() {
Some(uri) => {
if enhance { return Plan::Unsupported("Enhance is not wired for Heroic games yet".into()); }
let open = vec!["xdg-open".to_string(), uri.to_string()];
match cli { Some(cli) => Plan::Run(via_run(&cli, &["--detached".to_string()], open)), None => Plan::Run(open) }
}
None => Plan::Unsupported("no Heroic app name for this entry".into()),
},
Source::Heuristic => Plan::Unsupported("found on disk: add it with `summit add` and pick its executable to launch it".into()),
}
}
@@ -81,7 +90,7 @@ mod tests {
use super::*;
use crate::model::Kind;
fn entry(id: &str, source: Source, installed: bool, app: Option<u32>, path: Option<&str>) -> Entry {
Entry { id: id.into(), title: id.into(), source, kind: Kind::Game, installed, path: path.map(Into::into), steam_app_id: app, playtime_minutes: 0, last_played: None, reasons: vec![] }
Entry { id: id.into(), title: id.into(), source, kind: Kind::Game, installed, path: path.map(Into::into), steam_app_id: app, playtime_minutes: 0, last_played: None, launch_uri: None, reasons: vec![] }
}
const CLI: &str = "/usr/bin/summit";
fn cli() -> Option<&'static Path> { Some(Path::new(CLI)) }
@@ -124,6 +133,11 @@ mod tests {
assert_eq!(plan(&l, None, false), Plan::Run(vec!["lutris".into(), "lutris:rungame/celeste".into()]));
assert!(matches!(plan(&l, cli(), true), Plan::Unsupported(_)));
assert!(matches!(plan(&entry("heroic:epic:x", Source::Heroic, true, None, None), cli(), false), Plan::Unsupported(_)));
let mut h = entry("heroic:epic:quail", Source::Heroic, true, None, None);
h.launch_uri = Some("heroic://launch?appName=Quail&runner=legendary".into());
assert_eq!(argv(plan(&h, cli(), false)), "/usr/bin/summit run heroic:epic:quail --detached --title=heroic:epic:quail -- xdg-open heroic://launch?appName=Quail&runner=legendary");
assert_eq!(plan(&h, None, false), Plan::Run(vec!["xdg-open".into(), "heroic://launch?appName=Quail&runner=legendary".into()]));
assert!(matches!(plan(&h, cli(), true), Plan::Unsupported(_)));
assert!(matches!(plan(&entry("scan:/g", Source::Heuristic, true, None, Some("/g")), cli(), false), Plan::Unsupported(_)));
}
}
+3
View File
@@ -21,4 +21,7 @@ pub struct Entry {
pub playtime_minutes: u64,
pub last_played: Option<u64>,
pub reasons: Vec<String>,
/// A URL that starts the entry through its own launcher (Heroic: `heroic://launch?appName=..&runner=..`).
#[serde(default, skip_serializing_if = "Option::is_none")]
pub launch_uri: Option<String>,
}
+3 -3
View File
@@ -52,7 +52,7 @@ pub fn inspect_dir(dir: &Path) -> Option<Entry> {
return Some(Entry {
id: format!("scan:{}", dir.display()), title, source: Source::Heuristic, kind: Kind::Game,
installed: true, path: Some(dir.to_string_lossy().into_owned()), steam_app_id: None,
playtime_minutes: 0, last_played: None, reasons,
playtime_minutes: 0, last_played: None, reasons, launch_uri: None,
});
}
// No engine/store signal, but a Windows .exe on Linux stands out: list it as Software with the reason.
@@ -66,7 +66,7 @@ pub fn inspect_dir(dir: &Path) -> Option<Entry> {
id: format!("scan:{}", dir.display()), title, source: Source::Heuristic, kind: Kind::Software,
installed: true, path: Some(dir.to_string_lossy().into_owned()), steam_app_id: None,
playtime_minutes: 0, last_played: None,
reasons: vec![format!("Windows executable {first} (.exe) found outside a Wine prefix"), "no game-engine or store signature, so listed as software".into()],
launch_uri: None, reasons: vec![format!("Windows executable {first} (.exe) found outside a Wine prefix"), "no game-engine or store signature, so listed as software".into()],
});
}
}
@@ -126,7 +126,7 @@ mod tests {
}
#[test]
fn dedupe_compares_whole_path_components() {
let e = |p: &str| Entry { id: format!("scan:{p}"), title: p.into(), source: Source::Heuristic, kind: Kind::Game, installed: true, path: Some(p.into()), steam_app_id: None, playtime_minutes: 0, last_played: None, reasons: vec![] };
let e = |p: &str| Entry { id: format!("scan:{p}"), title: p.into(), source: Source::Heuristic, kind: Kind::Game, installed: true, path: Some(p.into()), steam_app_id: None, playtime_minutes: 0, last_played: None, launch_uri: None, reasons: vec![] };
let known = vec!["/games/Foo".to_string(), "/games/Bar/run.sh".to_string(), String::new()];
let kept: Vec<String> = dedupe(vec![e("/games/FooBar"), e("/games/Foo/sub"), e("/games/Bar"), e("/games/Baz")], &known)
.into_iter().filter_map(|x| x.path).collect();
+2 -2
View File
@@ -72,7 +72,7 @@ pub fn custom_entries(st: &State) -> Vec<crate::model::Entry> {
kind: if c.software { Kind::Software } else { Kind::Game },
installed: std::path::Path::new(&c.path).exists(), path: Some(c.path.clone()), steam_app_id: None,
playtime_minutes: 0, last_played: None,
reasons: vec![format!("added by you: {}", c.path)],
launch_uri: None, reasons: vec![format!("added by you: {}", c.path)],
}).collect()
}
@@ -95,7 +95,7 @@ mod tests {
use super::*;
use crate::model::*;
fn entry(id: &str, src: Source, pt: u64) -> Entry {
Entry { id: id.into(), title: id.into(), source: src, kind: Kind::Game, installed: true, path: None, steam_app_id: None, playtime_minutes: pt, last_played: None, reasons: vec![] }
Entry { id: id.into(), title: id.into(), source: src, kind: Kind::Game, installed: true, path: None, steam_app_id: None, playtime_minutes: pt, last_played: None, launch_uri: None, reasons: vec![] }
}
#[test]
fn steam_not_double_counted_others_tracked() {
+2 -1
View File
@@ -114,6 +114,7 @@ pub fn scan() -> Vec<Entry> {
steam_app_id: Some(id),
playtime_minutes: minutes,
last_played: if last > 0 { Some(last) } else { None },
launch_uri: None,
reasons,
});
}
@@ -127,7 +128,7 @@ pub fn scan() -> Vec<Entry> {
id: format!("steam:{id}"), title: n.name.clone(), source: Source::Steam, kind: Kind::Game,
installed: false, path: None, steam_app_id: Some(*id), playtime_minutes: *minutes,
last_played: if *last > 0 { Some(*last) } else { None },
reasons: vec![format!("app {id} is in your Steam account (localconfig.vdf)"), "not installed".into()],
launch_uri: None, reasons: vec![format!("app {id} is in your Steam account (localconfig.vdf)"), "not installed".into()],
});
}
}
+1 -1
View File
@@ -225,7 +225,7 @@ pub fn edit_apply(p: &Profile, outs: &[Output], row: usize, value: usize) -> Pro
mod tests {
use super::*;
fn e(id: &str, title: &str, kind: Kind, src: Source, installed: bool, minutes: u64, last: u64) -> Entry {
Entry { id: id.into(), title: title.into(), source: src, kind, installed, path: None, steam_app_id: None, playtime_minutes: minutes, last_played: if last > 0 { Some(last) } else { None }, reasons: vec![] }
Entry { id: id.into(), title: title.into(), source: src, kind, installed, path: None, steam_app_id: None, playtime_minutes: minutes, last_played: if last > 0 { Some(last) } else { None }, launch_uri: None, reasons: vec![] }
}
fn lib() -> Vec<Entry> {
vec![