diff --git a/common/application.cpp b/common/application.cpp index 370b6437..c4b2bc6a 100644 --- a/common/application.cpp +++ b/common/application.cpp @@ -116,7 +116,7 @@ std::vector load_steam_icon(const std::filesystem::path & root, int a return {}; } -void read_steam_vr_apps(std::unordered_map & res) +void read_steam_vr_apps(std::unordered_map & res, bool load_icons) { auto [command, root] = find_steam(); if (not root) @@ -166,17 +166,20 @@ void read_steam_vr_apps(std::unordered_map & res) } } - try + if (load_icons) { - const char prefix[] = "steam.app."; - if (app_key.starts_with(prefix)) + try + { + const char prefix[] = "steam.app."; + if (app_key.starts_with(prefix)) + { + uint32_t app_id = stoll(app_key.substr(strlen(prefix))); + app.image = load_steam_icon(*root, app_id, info); + } + } + catch (...) { - uint32_t app_id = stoll(app_key.substr(strlen(prefix))); - app.image = load_steam_icon(*root, app_id, info); } - } - catch (...) - { } if (not app.exec.empty()) @@ -278,7 +281,7 @@ bool contains(std::string_view entries, std::string_view val, char sep = ';') return false; } -std::optional do_desktop_entry(const std::filesystem::path & filename) +std::optional do_desktop_entry(const std::filesystem::path & filename, bool load_icons) { auto data = read_file(filename); std::optional res; @@ -320,10 +323,15 @@ std::optional do_desktop_entry(const std::filesystem::path & filena res->exec = unescape(item.value); if (item.key == "Path") res->path = unescape(item.value); - if (item.key == "Icon") + if (item.key == "Icon" and load_icons) { - if (auto filename = xdg_icon_lookup(std::string{item.value}, 256)) - res->image = load_icon(*filename, 256); + try + { + if (auto filename = xdg_icon_lookup(std::string{item.value}, 256)) + res->image = load_icon(*filename, 256); + } + catch (...) + {} } } @@ -333,7 +341,7 @@ std::optional do_desktop_entry(const std::filesystem::path & filena return res; } -void do_data_dir(std::filesystem::path dir, std::unordered_map & res) +void do_data_dir(std::filesystem::path dir, std::unordered_map & res, bool load_icons) { dir = dir / "applications"; if (not std::filesystem::is_directory(dir)) @@ -356,29 +364,29 @@ void do_data_dir(std::filesystem::path dir, std::unordered_map list_applications(bool include_steam) +std::unordered_map list_applications(bool include_steam, bool load_icons) { std::unordered_map res; if (include_steam) - read_steam_vr_apps(res); + read_steam_vr_apps(res, load_icons); - do_data_dir(xdg_data_home(), res); + do_data_dir(xdg_data_home(), res, load_icons); for (auto && dir: xdg_data_dirs()) - do_data_dir(std::move(dir), res); + do_data_dir(std::move(dir), res, load_icons); if (wivrn::is_flatpak()) { // Try to guess host data dirs - do_data_dir("/run/host/usr/share", res); + do_data_dir("/run/host/usr/share", res, load_icons); } return res; diff --git a/common/application.h b/common/application.h index 6c9314dd..38961247 100644 --- a/common/application.h +++ b/common/application.h @@ -35,5 +35,5 @@ struct application std::optional path; }; -std::unordered_map list_applications(bool include_steam = true); +std::unordered_map list_applications(bool include_steam = true, bool load_icons = true); } // namespace wivrn diff --git a/dashboard/apps.cpp b/dashboard/apps.cpp index 2ab62820..fe24bfa9 100644 --- a/dashboard/apps.cpp +++ b/dashboard/apps.cpp @@ -25,7 +25,7 @@ Apps::Apps(QObject * parent) { - auto apps = wivrn::list_applications(); + auto apps = wivrn::list_applications(true /* Include steam apps */, false /* Don't load icons */); for (const auto & [id, app]: apps) {