summaryrefslogtreecommitdiff
path: root/hyprctl/main.cpp
diff options
context:
space:
mode:
authorDarksome <dev@darkso.me>2022-07-21 19:18:03 +0300
committerDarksome <dev@darkso.me>2022-07-21 19:18:03 +0300
commiteb8a1939e6dddaaf81f6b623d1c657b801978487 (patch)
treed62d4ca30d4114fe2e2745e36907b65ac4be20af /hyprctl/main.cpp
parent68cfc1a496f556f360c032651b75d33ddb576517 (diff)
parent7f660fed0d4a8133ccde21c3e092dbc8c6e08c60 (diff)
Merge upstream
Diffstat (limited to 'hyprctl/main.cpp')
-rw-r--r--hyprctl/main.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/hyprctl/main.cpp b/hyprctl/main.cpp
index 8d9b6d96..4ff1aade 100644
--- a/hyprctl/main.cpp
+++ b/hyprctl/main.cpp
@@ -9,6 +9,8 @@
#include <sys/types.h>
#include <sys/un.h>
#include <unistd.h>
+#include <ranges>
+#include <algorithm>
#include <iostream>
#include <string>
@@ -202,6 +204,10 @@ std::deque<std::string> splitArgs(int argc, char** argv) {
return result;
}
+bool isNumber(const std::string& str, bool allowfloat) {
+ return std::ranges::all_of(str.begin(), str.end(), [&](char c) { return isdigit(c) != 0 || c == '-' || (allowfloat && c == '.'); });
+}
+
int main(int argc, char** argv) {
int bflag = 0, sflag = 0, index, c;
@@ -215,7 +221,7 @@ int main(int argc, char** argv) {
const auto ARGS = splitArgs(argc, argv);
for (auto i = 0; i < ARGS.size(); ++i) {
- if (ARGS[i][0] == '-') {
+ if (ARGS[i][0] == '-' && !isNumber(ARGS[i], true) /* For stuff like -2 */) {
// parse
if (ARGS[i] == "-j" && !fullArgs.contains("j")) {
fullArgs += "j";