| 58 | } |
| 59 | |
| 60 | std::optional<std::string> getDesktopFilePath(const std::string& app_identifier, |
| 61 | const std::string& alternative_app_identifier) { |
| 62 | if (app_identifier.empty()) { |
| 63 | return {}; |
| 64 | } |
| 65 | |
| 66 | auto data_dirs = Glib::get_system_data_dirs(); |
| 67 | data_dirs.insert(data_dirs.begin(), Glib::get_user_data_dir()); |
| 68 | for (const auto& data_dir : data_dirs) { |
| 69 | const auto data_app_dir = data_dir + "/applications/"; |
| 70 | auto desktop_file_suffix = app_identifier + ".desktop"; |
| 71 | // searching for file by suffix catches cases like terminal emulator "foot" where class is |
| 72 | // "footclient" and desktop file is named "org.codeberg.dnkl.footclient.desktop" |
| 73 | auto desktop_file_path = getFileBySuffix(data_app_dir, desktop_file_suffix, true); |
| 74 | // "true" argument allows checking for lowercase - this catches cases where class name is |
| 75 | // "LibreWolf" and desktop file is named "librewolf.desktop" |
| 76 | if (desktop_file_path.has_value()) { |
| 77 | return desktop_file_path; |
| 78 | } |
| 79 | if (!alternative_app_identifier.empty()) { |
| 80 | desktop_file_suffix = alternative_app_identifier + ".desktop"; |
| 81 | desktop_file_path = getFileBySuffix(data_app_dir, desktop_file_suffix, true); |
| 82 | if (desktop_file_path.has_value()) { |
| 83 | return desktop_file_path; |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | return {}; |
| 88 | } |
| 89 | |
| 90 | std::optional<Glib::ustring> getIconName(const std::string& app_identifier, |
| 91 | const std::string& alternative_app_identifier) { |
no test coverage detected