Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix for hyprctl --batch doesn't work with exec rules #8952

Merged
merged 3 commits into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 18 additions & 26 deletions src/debug/HyprCtl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1150,34 +1150,26 @@ static std::string cursorPosRequest(eHyprCtlOutputFormat format, std::string req
}

static std::string dispatchBatch(eHyprCtlOutputFormat format, std::string request) {
// split by ;

request = request.substr(9);
std::string curitem = "";
std::string reply = "";

auto nextItem = [&]() {
auto idx = request.find_first_of(';');

if (idx != std::string::npos) {
curitem = request.substr(0, idx);
request = request.substr(idx + 1);
} else {
curitem = request;
request = "";
}

curitem = trim(curitem);
};

nextItem();
// split by ; ignores ; inside [] and adds ; on last command

request = request.substr(9);
std::string reply = "";
const std::string DELIMITER = "\n\n\n";

while (curitem != "" || request != "") {
reply += g_pHyprCtl->getReply(curitem) + DELIMITER;

nextItem();
int bracket = 0;
size_t idx = 0;

for (size_t i = 0; i <= request.size(); ++i) {
char ch = (i < request.size()) ? request[i] : ';';
if (ch == '[')
++bracket;
else if (ch == ']')
--bracket;
else if (ch == ';' && bracket == 0) {
if (idx < i)
reply += g_pHyprCtl->getReply(trim(request.substr(idx, i - idx))).append(DELIMITER);
vaxerski marked this conversation as resolved.
Show resolved Hide resolved
idx = i + 1;
continue;
}
}

return reply.substr(0, std::max(static_cast<int>(reply.size() - DELIMITER.size()), 0));
Expand Down
Loading