aboutsummaryrefslogtreecommitdiffhomepage
path: root/hyprctl/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'hyprctl/main.cpp')
-rw-r--r--hyprctl/main.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/hyprctl/main.cpp b/hyprctl/main.cpp
index 8d9b6d96..9bfacaa2 100644
--- a/hyprctl/main.cpp
+++ b/hyprctl/main.cpp
@@ -202,6 +202,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 +219,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";