MCPcopy Create free account
hub / github.com/Alexays/Waybar / getDesktopFilePath

Function getDesktopFilePath

src/AAppIconLabel.cpp:60–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58}
59
60std::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
90std::optional<Glib::ustring> getIconName(const std::string& app_identifier,
91 const std::string& alternative_app_identifier) {

Callers 1

getIconNameFunction · 0.85

Calls 3

getFileBySuffixFunction · 0.85
emptyMethod · 0.80
beginMethod · 0.45

Tested by

no test coverage detected