Read non-Steam games using shortcuts.vdf

This commit is contained in:
Patrick Nicolas
2026-01-20 14:05:06 +01:00
parent 514c44b0a1
commit cc773294e3
3 changed files with 200 additions and 15 deletions
+29 -15
View File
@@ -138,6 +138,11 @@ void read_steam_vr_apps(std::unordered_map<std::string, application> & res)
{
application app;
if (i["launch_type"] == "url")
app.exec = command + " " + (std::string)i["url"];
else
continue;
std::string app_key = i["app_key"];
for (auto [locale, items]: i["strings"].items())
{
@@ -154,21 +159,6 @@ void read_steam_vr_apps(std::unordered_map<std::string, application> & res)
app.name[""] = it->second;
}
if (i["launch_type"] == "url")
{
app.exec = command + " " + (std::string)i["url"];
}
else if (i["launch_type"] == "binary")
{
const char prefix[] = "steam.app.";
if (app_key.starts_with(prefix))
{
// ¯\_(ツ)_/¯
uint64_t appkey = stoll(app_key.substr(strlen(prefix)));
app.exec = command + " steam://rungameid/" + std::to_string((appkey << 32) + 0x2000000);
}
}
try
{
const char prefix[] = "steam.app.";
@@ -190,6 +180,30 @@ void read_steam_vr_apps(std::unordered_map<std::string, application> & res)
std::cerr << "Failed to parse Steam VR manifest: " << e.what() << std::endl;
}
}
for (auto const & entry: std::filesystem::directory_iterator{*root / "userdata"})
{
auto shortcuts_vdf = entry.path() / "config/shortcuts.vdf";
if (std::filesystem::exists(shortcuts_vdf))
{
try
{
for (auto && item: read_steam_shortcuts(shortcuts_vdf))
{
res[std::to_string(item.appid)] = {
.name = {{"", std::move(item.name)}},
// ¯\_(ツ)_/¯
.exec = command + " steam://rungameid/" + std::to_string((uint64_t(item.appid) << 32) + 0x2000000),
.icon_path = std::move(item.icon),
};
}
}
catch (std::exception & e)
{
std::cerr << "Failed to parse Steam shortcuts file " << shortcuts_vdf << ": " << e.what() << std::endl;
}
}
}
}
std::string unescape(std::string_view in)