diff options
author | vaxerski <[email protected]> | 2022-08-11 21:28:37 +0200 |
---|---|---|
committer | vaxerski <[email protected]> | 2022-08-11 21:28:37 +0200 |
commit | ae175fdda536778d76b730ce09d42a8b3a47aa9b (patch) | |
tree | fdb32c0997971b251a0980e20f9ddd3cd8a9a950 | |
parent | 91024716103128ec74cf9a1da97889c74a676a3e (diff) | |
download | Hyprland-ae175fdda536778d76b730ce09d42a8b3a47aa9b.tar.gz Hyprland-ae175fdda536778d76b730ce09d42a8b3a47aa9b.zip |
handle json for hyprctl version
-rw-r--r-- | src/debug/HyprCtl.cpp | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index e09e4f8b..74b5bbe7 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -407,23 +407,56 @@ R"#( { return result; } -std::string versionRequest() { - std::string result = "Hyprland, built from branch " + std::string(GIT_BRANCH) + " at commit " + GIT_COMMIT_HASH + GIT_DIRTY + " (" + GIT_COMMIT_MESSAGE + ").\nflags: (if any)\n"; +std::string versionRequest(HyprCtl::eHyprCtlOutputFormat format) { + + if (format == HyprCtl::eHyprCtlOutputFormat::FORMAT_NORMAL) { + std::string result = "Hyprland, built from branch " + std::string(GIT_BRANCH) + " at commit " + GIT_COMMIT_HASH + GIT_DIRTY + " (" + removeBeginEndSpacesTabs(GIT_COMMIT_MESSAGE).c_str() + ").\nflags: (if any)\n"; #ifdef LEGACY_RENDERER - result += "legacyrenderer\n"; + result += "legacyrenderer\n"; #endif #ifndef NDEBUG - result += "debug\n"; + result += "debug\n"; #endif #ifdef HYPRLAND_DEBUG - result += "debug\n"; + result += "debug\n"; #endif #ifdef NO_XWAYLAND - result += "no xwayland\n"; + result += "no xwayland\n"; #endif - return result; + return result; + } else { + std::string result = getFormat( +R"#({ + "branch": "%s", + "commit": "%s", + "dirty": %s + "commit_message": "%s", + "flags" = [)#", GIT_BRANCH, GIT_COMMIT_HASH, (strcmp(GIT_DIRTY, "dirty") == 0 ? "true" : "false"), removeBeginEndSpacesTabs(GIT_COMMIT_MESSAGE).c_str()); + +#ifdef LEGACY_RENDERER + result += "\"legacyrenderer\","; +#endif +#ifndef NDEBUG + result += "\"debug\","; +#endif +#ifdef HYPRLAND_DEBUG + result += "\"debug\","; +#endif +#ifdef NO_XWAYLAND + result += "\"no xwayland\","; +#endif + + if (result[result.length() - 1] == ',') + result.pop_back(); + + result += "]\n}"; + + return result; + } + + return ""; // make the compiler happy } std::string dispatchRequest(std::string in) { @@ -647,7 +680,7 @@ std::string getReply(std::string request) { else if (request == "layers") return layersRequest(format); else if (request == "version") - return versionRequest(); + return versionRequest(format); else if (request == "reload") return reloadRequest(); else if (request == "devices") |