aboutsummaryrefslogtreecommitdiffhomepage
path: root/hyprctl
diff options
context:
space:
mode:
authorKhalid <[email protected]>2024-03-26 16:38:54 +0300
committerGitHub <[email protected]>2024-03-26 13:38:54 +0000
commit9b7ae25ae83b5b0d6f61fe542391301a57d31270 (patch)
tree93466e6d82268c280494c92e3b71c4d7538c510d /hyprctl
parent1a0b8d1263a318146ce63062115332c725e79edf (diff)
downloadHyprland-9b7ae25ae83b5b0d6f61fe542391301a57d31270.tar.gz
Hyprland-9b7ae25ae83b5b0d6f61fe542391301a57d31270.zip
hyprctl: output json with `--batch` if requested (#5277)
Diffstat (limited to 'hyprctl')
-rw-r--r--hyprctl/main.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/hyprctl/main.cpp b/hyprctl/main.cpp
index b8072de9..0bf6f414 100644
--- a/hyprctl/main.cpp
+++ b/hyprctl/main.cpp
@@ -22,6 +22,7 @@
#include <deque>
#include <filesystem>
#include <stdarg.h>
+#include <regex>
const std::string USAGE = R"#(usage: hyprctl [(opt)flags] [command] [(opt)args]
@@ -234,9 +235,14 @@ void requestHyprpaper(std::string arg) {
std::cout << std::string(buffer);
}
-void batchRequest(std::string arg) {
- std::string rq = "[[BATCH]]" + arg.substr(arg.find_first_of(" ") + 1);
+void batchRequest(std::string arg, bool json) {
+ std::string commands = arg.substr(arg.find_first_of(" ") + 1);
+ if (json) {
+ commands = "j/" + std::regex_replace(commands, std::regex(";\\s*"), ";j/");
+ }
+
+ std::string rq = "[[BATCH]]" + commands;
request(rq);
}
@@ -383,7 +389,7 @@ int main(int argc, char** argv) {
int exitStatus = 0;
if (fullRequest.contains("/--batch"))
- batchRequest(fullRequest);
+ batchRequest(fullRequest, json);
else if (fullRequest.contains("/hyprpaper"))
requestHyprpaper(fullRequest);
else if (fullRequest.contains("/switchxkblayout"))