mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-07 18:45:59 +01:00
fixed up hyprctl flags
This commit is contained in:
parent
c0377457df
commit
ba48e7ceea
1 changed files with 32 additions and 6 deletions
|
@ -14,8 +14,9 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <deque>
|
||||||
|
|
||||||
const std::string USAGE = R"#(usage: hyprctl [(opt)flag /][command] [(opt)args]
|
const std::string USAGE = R"#(usage: hyprctl [(opt)flags] [command] [(opt)args]
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
monitors
|
monitors
|
||||||
|
@ -192,6 +193,15 @@ void batchRequest(std::string arg) {
|
||||||
request(rq);
|
request(rq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::deque<std::string> splitArgs(int argc, char** argv) {
|
||||||
|
std::deque<std::string> result;
|
||||||
|
|
||||||
|
for (auto i = 1 /* skip the executable */; i < argc; ++i)
|
||||||
|
result.push_back(std::string(argv[i]));
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
int bflag = 0, sflag = 0, index, c;
|
int bflag = 0, sflag = 0, index, c;
|
||||||
|
|
||||||
|
@ -201,14 +211,30 @@ int main(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string fullRequest = "";
|
std::string fullRequest = "";
|
||||||
for (int i = 1; i < argc; i++) {
|
std::string fullArgs = "";
|
||||||
fullRequest += std::string(argv[i]) + " ";
|
const auto ARGS = splitArgs(argc, argv);
|
||||||
|
|
||||||
|
for (auto i = 0; i < ARGS.size(); ++i) {
|
||||||
|
if (ARGS[i].contains("-")) {
|
||||||
|
// parse
|
||||||
|
if (ARGS[i] == "-j" && !fullArgs.contains("j")) {
|
||||||
|
fullArgs += "j";
|
||||||
|
} else if (ARGS[i] == "--batch") {
|
||||||
|
fullRequest = "--batch ";
|
||||||
|
} else {
|
||||||
|
printf("%s\n", USAGE.c_str());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
fullRequest += ARGS[i] + " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
fullRequest.pop_back(); // remove trailing space
|
fullRequest.pop_back(); // remove trailing space
|
||||||
|
|
||||||
if (!std::string(argv[1]).contains("/")) {
|
fullRequest = fullArgs + "/" + fullRequest;
|
||||||
fullRequest = "/" + fullRequest;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fullRequest.contains("/--batch")) batchRequest(fullRequest);
|
if (fullRequest.contains("/--batch")) batchRequest(fullRequest);
|
||||||
else if (fullRequest.contains("/monitors")) request(fullRequest);
|
else if (fullRequest.contains("/monitors")) request(fullRequest);
|
||||||
|
|
Loading…
Reference in a new issue