Allow arguments to hyprctl dispatch exec commands. (#990)

This commit is contained in:
Philip Jones 2022-11-10 15:36:36 +00:00 committed by GitHub
parent 153c99217d
commit 27cada2a02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -168,8 +168,11 @@ int dispatchRequest(int argc, char** argv) {
std::string rq = "/dispatch"; std::string rq = "/dispatch";
for(int i = 2; i < argc; i++) for(int i = 2; i < argc; i++) {
if (!strcmp(argv[i], "--"))
continue;
rq += " " + std::string(argv[i]); rq += " " + std::string(argv[i]);
}
request(rq); request(rq);
return 0; return 0;
@ -253,6 +256,7 @@ bool isNumber(const std::string& str, bool allowfloat) {
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;
bool parseArgs = true;
if (argc < 2) { if (argc < 2) {
printf("%s\n", USAGE.c_str()); printf("%s\n", USAGE.c_str());
@ -264,7 +268,12 @@ int main(int argc, char** argv) {
const auto ARGS = splitArgs(argc, argv); const auto ARGS = splitArgs(argc, argv);
for (auto i = 0; i < ARGS.size(); ++i) { for (auto i = 0; i < ARGS.size(); ++i) {
if (ARGS[i][0] == '-' && !isNumber(ARGS[i], true) /* For stuff like -2 */) { if (ARGS[i] == "--") {
// Stop parsing arguments after --
parseArgs = false;
continue;
}
if (parseArgs && (ARGS[i][0] == '-') && !isNumber(ARGS[i], true) /* For stuff like -2 */) {
// parse // parse
if (ARGS[i] == "-j" && !fullArgs.contains("j")) { if (ARGS[i] == "-j" && !fullArgs.contains("j")) {
fullArgs += "j"; fullArgs += "j";