From b865dabebab717fea75f91e8ccebabc99e36bdd9 Mon Sep 17 00:00:00 2001 From: Connor E <38229097+c-edw@users.noreply.github.com> Date: Sat, 10 Nov 2018 12:55:06 +0000 Subject: Use parse_boolean where possible. --- sway/commands/input/xkb_capslock.c | 10 ++-------- sway/commands/input/xkb_numlock.c | 10 ++-------- 2 files changed, 4 insertions(+), 16 deletions(-) (limited to 'sway/commands/input') diff --git a/sway/commands/input/xkb_capslock.c b/sway/commands/input/xkb_capslock.c index 669b4ea9..a939c72f 100644 --- a/sway/commands/input/xkb_capslock.c +++ b/sway/commands/input/xkb_capslock.c @@ -3,6 +3,7 @@ #include "sway/config.h" #include "sway/commands.h" #include "sway/input/input-manager.h" +#include "util.h" struct cmd_results *input_cmd_xkb_capslock(int argc, char **argv) { struct cmd_results *error = NULL; @@ -15,14 +16,7 @@ struct cmd_results *input_cmd_xkb_capslock(int argc, char **argv) { "No input device defined."); } - if (strcasecmp(argv[0], "enabled") == 0) { - ic->xkb_capslock = 1; - } else if (strcasecmp(argv[0], "disabled") == 0) { - ic->xkb_capslock = 0; - } else { - return cmd_results_new(CMD_INVALID, "xkb_capslock", - "Expected 'xkb_capslock '"); - } + ic->xkb_capslock = parse_boolean(argv[0], false); return cmd_results_new(CMD_SUCCESS, NULL, NULL); } diff --git a/sway/commands/input/xkb_numlock.c b/sway/commands/input/xkb_numlock.c index 1367da44..2e962c5b 100644 --- a/sway/commands/input/xkb_numlock.c +++ b/sway/commands/input/xkb_numlock.c @@ -3,6 +3,7 @@ #include "sway/config.h" #include "sway/commands.h" #include "sway/input/input-manager.h" +#include "util.h" struct cmd_results *input_cmd_xkb_numlock(int argc, char **argv) { struct cmd_results *error = NULL; @@ -15,14 +16,7 @@ struct cmd_results *input_cmd_xkb_numlock(int argc, char **argv) { "No input device defined."); } - if (strcasecmp(argv[0], "enabled") == 0) { - ic->xkb_numlock = 1; - } else if (strcasecmp(argv[0], "disabled") == 0) { - ic->xkb_numlock = 0; - } else { - return cmd_results_new(CMD_INVALID, "xkb_numlock", - "Expected 'xkb_numlock '"); - } + ic->xkb_numlock = parse_boolean(argv[0], false); return cmd_results_new(CMD_SUCCESS, NULL, NULL); } -- cgit v1.2.3