summaryrefslogtreecommitdiffstats
path: root/sway/commands/force_display_urgency_hint.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/force_display_urgency_hint.c')
-rw-r--r--sway/commands/force_display_urgency_hint.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/sway/commands/force_display_urgency_hint.c b/sway/commands/force_display_urgency_hint.c
index 3202fc43..3d432cba 100644
--- a/sway/commands/force_display_urgency_hint.c
+++ b/sway/commands/force_display_urgency_hint.c
@@ -1,5 +1,6 @@
1#include "sway/commands.h" 1#include "sway/commands.h"
2#include "sway/config.h" 2#include "sway/config.h"
3#include <errno.h>
3 4
4struct cmd_results *cmd_force_display_urgency_hint(int argc, char **argv) { 5struct cmd_results *cmd_force_display_urgency_hint(int argc, char **argv) {
5 struct cmd_results *error = NULL; 6 struct cmd_results *error = NULL;
@@ -8,13 +9,16 @@ struct cmd_results *cmd_force_display_urgency_hint(int argc, char **argv) {
8 return error; 9 return error;
9 } 10 }
10 11
11 char *err; 12 errno = 0;
12 int timeout = (int)strtol(argv[0], &err, 10); 13 char *end;
13 if (*err) { 14 int timeout = (int)strtol(argv[0], &end, 10);
14 if (strcmp(err, "ms") != 0) { 15 if (errno || end == argv[0] || (*end && strcmp(end, "ms") != 0)) {
15 return cmd_results_new(CMD_INVALID, 16 return cmd_results_new(CMD_INVALID, "timeout integer invalid");
16 "Expected 'force_display_urgency_hint <timeout> ms'"); 17 }
17 } 18
19 if (argc > 1 && strcmp(argv[1], "ms") != 0) {
20 return cmd_results_new(CMD_INVALID,
21 "Expected 'force_display_urgency_hint <timeout> [ms]'");
18 } 22 }
19 23
20 config->urgent_timeout = timeout > 0 ? timeout : 0; 24 config->urgent_timeout = timeout > 0 ? timeout : 0;