diff options
author | vaxerski <[email protected]> | 2022-12-03 15:56:07 +0000 |
---|---|---|
committer | vaxerski <[email protected]> | 2022-12-03 16:22:02 +0000 |
commit | 6aa26582f63c13e32dd0191015550a2d1eade7e6 (patch) | |
tree | 7733216f18318ffb840c5d681df6b2a9cd80626e /hyprctl/main.cpp | |
parent | 056a45d035781a74ae80d5a5f0247f3338dca05d (diff) | |
download | Hyprland-6aa26582f63c13e32dd0191015550a2d1eade7e6.tar.gz Hyprland-6aa26582f63c13e32dd0191015550a2d1eade7e6.zip |
added hyprctl switchxkblayout
Diffstat (limited to 'hyprctl/main.cpp')
-rw-r--r-- | hyprctl/main.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/hyprctl/main.cpp b/hyprctl/main.cpp index 516a3080..0d8dc5d0 100644 --- a/hyprctl/main.cpp +++ b/hyprctl/main.cpp @@ -37,15 +37,23 @@ commands: setcursor getoption cursorpos + switchxkblayout flags: -j -> output in JSON --batch -> execute a batch of commands, separated by ';' )#"; -void request(std::string arg) { +void request(std::string arg, int minArgs = 0) { const auto SERVERSOCKET = socket(AF_UNIX, SOCK_STREAM, 0); + const auto ARGS = std::count(arg.begin(), arg.end(), ' '); + + if (ARGS < minArgs) { + std::cout << "Not enough arguments, expected at least " << minArgs; + return; + } + if (SERVERSOCKET < 0) { std::cout << "Couldn't open a socket (1)"; return; @@ -316,6 +324,7 @@ int main(int argc, char** argv) { else if (fullRequest.contains("/reload")) request(fullRequest); else if (fullRequest.contains("/getoption")) request(fullRequest); else if (fullRequest.contains("/cursorpos")) request(fullRequest); + else if (fullRequest.contains("/switchxkblayout")) request(fullRequest, 2); else if (fullRequest.contains("/output")) exitStatus = outputRequest(argc, argv); else if (fullRequest.contains("/setcursor")) exitStatus = setcursorRequest(argc, argv); else if (fullRequest.contains("/dispatch")) exitStatus = dispatchRequest(argc, argv); |