diff options
| author | bazuin-32 <ameenpiano@gmail.com> | 2022-07-12 14:59:36 -0600 |
|---|---|---|
| committer | bazuin-32 <ameenpiano@gmail.com> | 2022-07-12 14:59:36 -0600 |
| commit | 2402f2e36498686dfebe7c06f1203f595b888252 (patch) | |
| tree | 4d39f52c9e835c6af91b95e026c29c4273cfc760 /hyprctl/main.cpp | |
| parent | 036f431206b6c530497fb6e204c9765745c2c17d (diff) | |
Use enum for specifying hyprctl output format and change the way flags
are passed for json output
Diffstat (limited to 'hyprctl/main.cpp')
| -rw-r--r-- | hyprctl/main.cpp | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/hyprctl/main.cpp b/hyprctl/main.cpp index 291fc207..5ab170e6 100644 --- a/hyprctl/main.cpp +++ b/hyprctl/main.cpp @@ -195,28 +195,29 @@ int main(int argc, char** argv) { return 1; } - std::string args(argv[1]); - - if (argc > 2) { - args += " "; - args += argv[2]; - } - - if (!strcmp(argv[1], "monitors")) request(args); - else if (!strcmp(argv[1], "clients")) request(args); - else if (!strcmp(argv[1], "workspaces")) request(args); - else if (!strcmp(argv[1], "activewindow")) request(args); - else if (!strcmp(argv[1], "layers")) request(args); - else if (!strcmp(argv[1], "version")) request(args); - else if (!strcmp(argv[1], "kill")) request(args); - else if (!strcmp(argv[1], "splash")) request(args); - else if (!strcmp(argv[1], "devices")) request(args); - else if (!strcmp(argv[1], "reload")) request(args); - else if (!strcmp(argv[1], "dispatch")) dispatchRequest(argc, argv); - else if (!strcmp(argv[1], "keyword")) keywordRequest(argc, argv); - else if (!strcmp(argv[1], "hyprpaper")) hyprpaperRequest(argc, argv); - else if (!strcmp(argv[1], "--batch")) batchRequest(argc, argv); - else if (!strcmp(argv[1], "--help")) printf("%s", USAGE.c_str()); + std::string ourRequest = argv[1]; + + if (!ourRequest.contains("/")) { + ourRequest = "/" + ourRequest; + } + + ourRequest.contains("/"); + + if (ourRequest.contains("/monitors")) request(ourRequest); + else if (ourRequest.contains("/clients")) request(ourRequest); + else if (ourRequest.contains("/workspaces")) request(ourRequest); + else if (ourRequest.contains("/activewindow")) request(ourRequest); + else if (ourRequest.contains("/layers")) request(ourRequest); + else if (ourRequest.contains("/version")) request(ourRequest); + else if (ourRequest.contains("/kill")) request(ourRequest); + else if (ourRequest.contains("/splash")) request(ourRequest); + else if (ourRequest.contains("/devices")) request(ourRequest); + else if (ourRequest.contains("/reload")) request(ourRequest); + else if (ourRequest.contains("/dispatch")) dispatchRequest(argc, argv); + else if (ourRequest.contains("/keyword")) keywordRequest(argc, argv); + else if (ourRequest.contains("/hyprpaper")) hyprpaperRequest(argc, argv); + else if (ourRequest.contains("/--batch")) batchRequest(argc, argv); + else if (ourRequest.contains("/--help")) printf("%s", USAGE.c_str()); else { printf("%s\n", USAGE.c_str()); return 1; |
