aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorToni500github <[email protected]>2024-10-11 13:19:16 +0200
committerGitHub <[email protected]>2024-10-11 12:19:16 +0100
commit7564b26b7d386d248eaa47c1a481c09eefd8e3ca (patch)
treea69321b879c4f4b2ab44466963a3126f981a9864 /src
parent178a300eeaf006fed4c8c9a599657b4530f65559 (diff)
downloadHyprland-7564b26b7d386d248eaa47c1a481c09eefd8e3ca.tar.gz
Hyprland-7564b26b7d386d248eaa47c1a481c09eefd8e3ca.zip
internal: improve version query and define HYPRLAND_VERSION (#8034)
Diffstat (limited to 'src')
-rw-r--r--src/debug/HyprCtl.cpp25
-rw-r--r--src/debug/HyprCtl.hpp1
-rw-r--r--src/main.cpp34
3 files changed, 22 insertions, 38 deletions
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp
index d9274727..e0bb2b83 100644
--- a/src/debug/HyprCtl.cpp
+++ b/src/debug/HyprCtl.cpp
@@ -853,26 +853,33 @@ std::string versionRequest(eHyprCtlOutputFormat format, std::string request) {
std::replace(commitMsg.begin(), commitMsg.end(), '#', ' ');
if (format == eHyprCtlOutputFormat::FORMAT_NORMAL) {
- std::string result = "Hyprland, built from branch " + std::string(GIT_BRANCH) + " at commit " + GIT_COMMIT_HASH + " " + GIT_DIRTY + " (" + commitMsg +
- ").\nDate: " + GIT_COMMIT_DATE + "\nTag: " + GIT_TAG + ", commits: " + GIT_COMMITS + std::string{"\nbuilt against aquamarine "} + AQUAMARINE_VERSION + "\n" +
- "\n\nflags: (if any)\n";
-
+ std::string result = std::format("Hyprland {} built from branch {} at commit {} {} ({}).\n"
+ "Date: {}\n"
+ "Tag: {}, commits: {}\n"
+ "built against aquamarine {}\n\n\n",
+ HYPRLAND_VERSION, GIT_BRANCH, GIT_COMMIT_HASH, GIT_DIRTY, commitMsg, GIT_COMMIT_DATE, GIT_TAG, GIT_COMMITS, AQUAMARINE_VERSION);
+
+#if (!defined(LEGACY_RENDERER) && !defined(ISDEBUG) && !defined(NO_XWAYLAND))
+ result += "no flags were set\n";
+#else
+ result += "flags set:\n";
#ifdef LEGACY_RENDERER
result += "legacyrenderer\n";
#endif
-#ifndef ISDEBUG
+#ifdef ISDEBUG
result += "debug\n";
#endif
#ifdef NO_XWAYLAND
result += "no xwayland\n";
#endif
-
+#endif
return result;
} else {
std::string result = std::format(
R"#({{
"branch": "{}",
"commit": "{}",
+ "version": "{}",
"dirty": {},
"commit_message": "{}",
"commit_date": "{}",
@@ -880,13 +887,13 @@ std::string versionRequest(eHyprCtlOutputFormat format, std::string request) {
"commits": "{}",
"buildAquamarine": "{}",
"flags": [)#",
- GIT_BRANCH, GIT_COMMIT_HASH, (strcmp(GIT_DIRTY, "dirty") == 0 ? "true" : "false"), escapeJSONStrings(commitMsg), GIT_COMMIT_DATE, GIT_TAG, GIT_COMMITS,
- AQUAMARINE_VERSION);
+ GIT_BRANCH, GIT_COMMIT_HASH, HYPRLAND_VERSION, (strcmp(GIT_DIRTY, "dirty") == 0 ? "true" : "false"), escapeJSONStrings(commitMsg), GIT_COMMIT_DATE, GIT_TAG,
+ GIT_COMMITS, AQUAMARINE_VERSION);
#ifdef LEGACY_RENDERER
result += "\"legacyrenderer\",";
#endif
-#ifndef ISDEBUG
+#ifdef ISDEBUG
result += "\"debug\",";
#endif
#ifdef NO_XWAYLAND
diff --git a/src/debug/HyprCtl.hpp b/src/debug/HyprCtl.hpp
index d68bf14f..c1bf51ca 100644
--- a/src/debug/HyprCtl.hpp
+++ b/src/debug/HyprCtl.hpp
@@ -7,6 +7,7 @@
// exposed for main.cpp
std::string systemInfoRequest(eHyprCtlOutputFormat format, std::string request);
+std::string versionRequest(eHyprCtlOutputFormat format, std::string request);
class CHyprCtl {
public:
diff --git a/src/main.cpp b/src/main.cpp
index 57bb5507..45f212d3 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -23,6 +23,7 @@ void help() {
std::cout << " --config FILE -c FILE - Specify config file to use\n";
std::cout << " --socket NAME - Sets the Wayland socket name (for Wayland socket handover)\n";
std::cout << " --wayland-fd FD - Sets the Wayland socket fd (for Wayland socket handover)\n";
+ std::cout << " --systeminfo - Prints system infos\n";
std::cout << " --i-am-really-stupid - Omits root user privileges check (why would you do that?)\n";
std::cout << " --version -v - Print this binary's version\n";
}
@@ -33,9 +34,9 @@ int main(int argc, char** argv) {
throwError("XDG_RUNTIME_DIR is not set!");
// export HYPRLAND_CMD
- std::string cmd = "";
- for (auto i = 0; i < argc; ++i)
- cmd += std::string(i == 0 ? "" : " ") + argv[i];
+ std::string cmd = argv[0];
+ for (int i = 1; i < argc; ++i)
+ cmd += std::string(" ") + argv[i];
setenv("HYPRLAND_CMD", cmd.c_str(), 1);
setenv("XDG_BACKEND", "wayland", 1);
@@ -116,32 +117,7 @@ int main(int argc, char** argv) {
return 0;
} else if (it->compare("-v") == 0 || it->compare("--version") == 0) {
- auto result = "Hyprland, built from branch " + std::string(GIT_BRANCH) + " at commit " + GIT_COMMIT_HASH;
- auto dirty = std::string(GIT_DIRTY);
- if (!dirty.empty())
- result += " " + dirty;
-
- auto commitMsg = trim(GIT_COMMIT_MESSAGE);
- std::replace(commitMsg.begin(), commitMsg.end(), '#', ' ');
- result += " (" + commitMsg + ").";
-
- result += "\nDate: " + std::string(GIT_COMMIT_DATE);
- result += "\nTag: " + std::string(GIT_TAG) + ", commits: " + std::string(GIT_COMMITS);
- result += "\nbuilt against aquamarine " + std::string(AQUAMARINE_VERSION);
-
- result += "\n\nflags: (if any)\n";
-
-#ifdef LEGACY_RENDERER
- result += "legacyrenderer\n";
-#endif
-#ifndef ISDEBUG
- result += "debug\n";
-#endif
-#ifdef NO_XWAYLAND
- result += "no xwayland\n";
-#endif
-
- std::cout << result;
+ std::cout << versionRequest(eHyprCtlOutputFormat::FORMAT_NORMAL, "") << std::endl;
return 0;
} else if (it->compare("--systeminfo") == 0) {
const auto SYSINFO = systemInfoRequest(eHyprCtlOutputFormat::FORMAT_NORMAL, "");