summaryrefslogtreecommitdiff
path: root/src/helpers/MiscFunctions.cpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2025-10-06 23:20:21 +0200
committerGitHub <noreply@github.com>2025-10-06 23:20:21 +0200
commit02cda6bebf327e85c8b238961ce0514a66b92709 (patch)
tree305e7c95863c4e91e67546857be07f895d9b3252 /src/helpers/MiscFunctions.cpp
parent73f06434a43c75b3a81e31a6ed7586a14a9c7a48 (diff)
systeminfo: log system package versions (#11946)
Diffstat (limited to 'src/helpers/MiscFunctions.cpp')
-rw-r--r--src/helpers/MiscFunctions.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp
index 2b6160c7..50a89622 100644
--- a/src/helpers/MiscFunctions.cpp
+++ b/src/helpers/MiscFunctions.cpp
@@ -929,3 +929,41 @@ std::string deviceNameToInternalString(std::string in) {
std::ranges::transform(in, in.begin(), ::tolower);
return in;
}
+
+static const std::vector<const char*> PKGCONF_PATHS = {"/usr/lib/pkgconfig", "/usr/local/lib/pkgconfig"};
+
+//
+std::string getSystemLibraryVersion(const std::string& name) {
+ for (const auto& pkgconf : PKGCONF_PATHS) {
+ std::error_code ec;
+ const std::string PATH = std::string{pkgconf} + "/" + name + ".pc";
+ if (!std::filesystem::exists(PATH, ec))
+ continue;
+
+ const auto DATA = NFsUtils::readFileAsString(PATH);
+
+ if (!DATA)
+ continue;
+
+ size_t versionAt = DATA->find("\nVersion: ");
+ size_t versionAtEnd = DATA->find("\n", versionAt + 11);
+
+ if (versionAt == std::string::npos)
+ continue;
+
+ versionAt += 10;
+
+ return DATA->substr(versionAt, versionAtEnd == std::string::npos ? std::string::npos : versionAtEnd - versionAt);
+ }
+ return "unknown";
+}
+
+std::string getBuiltSystemLibraryNames() {
+ std::string result = "Libraries:\n";
+ result += std::format("Hyprgraphics: built against {}, system has {}\n", HYPRGRAPHICS_VERSION, getSystemLibraryVersion("hyprgraphics"));
+ result += std::format("Hyprutils: built against {}, system has {}\n", HYPRUTILS_VERSION, getSystemLibraryVersion("hyprutils"));
+ result += std::format("Hyprcursor: built against {}, system has {}\n", HYPRCURSOR_VERSION, getSystemLibraryVersion("hyprcursor"));
+ result += std::format("Hyprlang: built against {}, system has {}\n", HYPRLANG_VERSION, getSystemLibraryVersion("hyprlang"));
+ result += std::format("Aquamarine: built against {}, system has {}\n", AQUAMARINE_VERSION, getSystemLibraryVersion("aquamarine"));
+ return result;
+}