diff options
author | Connor E <38229097+c-edw@users.noreply.github.com> | 2018-11-10 12:55:06 +0000 |
---|---|---|
committer | Connor E <38229097+c-edw@users.noreply.github.com> | 2018-11-10 12:55:06 +0000 |
commit | b865dabebab717fea75f91e8ccebabc99e36bdd9 (patch) | |
tree | df51bf83b899933f1347508b9f1bd55aefa21ae5 /sway/commands/bar | |
parent | 7fa7f4f48d17e0470c800b258061d188ceb705da (diff) |
Use parse_boolean where possible.
Diffstat (limited to 'sway/commands/bar')
-rw-r--r-- | sway/commands/bar/binding_mode_indicator.c | 12 | ||||
-rw-r--r-- | sway/commands/bar/pango_markup.c | 13 | ||||
-rw-r--r-- | sway/commands/bar/workspace_buttons.c | 12 | ||||
-rw-r--r-- | sway/commands/bar/wrap_scroll.c | 14 |
4 files changed, 21 insertions, 30 deletions
diff --git a/sway/commands/bar/binding_mode_indicator.c b/sway/commands/bar/binding_mode_indicator.c index f18b8d7c..b048b7b9 100644 --- a/sway/commands/bar/binding_mode_indicator.c +++ b/sway/commands/bar/binding_mode_indicator.c @@ -2,6 +2,7 @@ #include <strings.h> #include "sway/commands.h" #include "log.h" +#include "util.h" struct cmd_results *bar_cmd_binding_mode_indicator(int argc, char **argv) { struct cmd_results *error = NULL; @@ -13,17 +14,14 @@ struct cmd_results *bar_cmd_binding_mode_indicator(int argc, char **argv) { return cmd_results_new(CMD_FAILURE, "binding_mode_indicator", "No bar defined."); } - if (strcasecmp("yes", argv[0]) == 0) { - config->current_bar->binding_mode_indicator = true; + config->current_bar->binding_mode_indicator = + parse_boolean(argv[0], config->current_bar->binding_mode_indicator); + if (config->current_bar->binding_mode_indicator) { wlr_log(WLR_DEBUG, "Enabling binding mode indicator on bar: %s", config->current_bar->id); - } else if (strcasecmp("no", argv[0]) == 0) { - config->current_bar->binding_mode_indicator = false; + } else { wlr_log(WLR_DEBUG, "Disabling binding mode indicator on bar: %s", config->current_bar->id); - } else { - return cmd_results_new(CMD_INVALID, "binding_mode_indicator", - "Invalid value %s", argv[0]); } return cmd_results_new(CMD_SUCCESS, NULL, NULL); } diff --git a/sway/commands/bar/pango_markup.c b/sway/commands/bar/pango_markup.c index 857571fb..d57cc45c 100644 --- a/sway/commands/bar/pango_markup.c +++ b/sway/commands/bar/pango_markup.c @@ -2,6 +2,7 @@ #include <strings.h> #include "sway/commands.h" #include "log.h" +#include "util.h" struct cmd_results *bar_cmd_pango_markup(int argc, char **argv) { struct cmd_results *error = NULL; @@ -11,18 +12,14 @@ struct cmd_results *bar_cmd_pango_markup(int argc, char **argv) { if (!config->current_bar) { return cmd_results_new(CMD_FAILURE, "pango_markup", "No bar defined."); } - if (strcasecmp("enabled", argv[0]) == 0) { - config->current_bar->pango_markup = true; + config->current_bar->pango_markup + = parse_boolean(argv[0], config->current_bar->pango_markup); + if (config->current_bar->pango_markup) { wlr_log(WLR_DEBUG, "Enabling pango markup for bar: %s", config->current_bar->id); - } else if (strcasecmp("disabled", argv[0]) == 0) { - config->current_bar->pango_markup = false; + } else { wlr_log(WLR_DEBUG, "Disabling pango markup for bar: %s", config->current_bar->id); - } else { - error = cmd_results_new(CMD_INVALID, "pango_markup", - "Invalid value %s", argv[0]); - return error; } return cmd_results_new(CMD_SUCCESS, NULL, NULL); } diff --git a/sway/commands/bar/workspace_buttons.c b/sway/commands/bar/workspace_buttons.c index a4079b2a..cd001e20 100644 --- a/sway/commands/bar/workspace_buttons.c +++ b/sway/commands/bar/workspace_buttons.c @@ -2,6 +2,7 @@ #include <strings.h> #include "sway/commands.h" #include "log.h" +#include "util.h" struct cmd_results *bar_cmd_workspace_buttons(int argc, char **argv) { struct cmd_results *error = NULL; @@ -12,17 +13,14 @@ struct cmd_results *bar_cmd_workspace_buttons(int argc, char **argv) { return cmd_results_new(CMD_FAILURE, "workspace_buttons", "No bar defined."); } - if (strcasecmp("yes", argv[0]) == 0) { - config->current_bar->workspace_buttons = true; + config->current_bar->workspace_buttons = + parse_boolean(argv[0], config->current_bar->workspace_buttons); + if (config->current_bar->workspace_buttons) { wlr_log(WLR_DEBUG, "Enabling workspace buttons on bar: %s", config->current_bar->id); - } else if (strcasecmp("no", argv[0]) == 0) { - config->current_bar->workspace_buttons = false; + } else { wlr_log(WLR_DEBUG, "Disabling workspace buttons on bar: %s", config->current_bar->id); - } else { - return cmd_results_new(CMD_INVALID, "workspace_buttons", - "Invalid value %s", argv[0]); } return cmd_results_new(CMD_SUCCESS, NULL, NULL); } diff --git a/sway/commands/bar/wrap_scroll.c b/sway/commands/bar/wrap_scroll.c index 701de00a..04a4e6b8 100644 --- a/sway/commands/bar/wrap_scroll.c +++ b/sway/commands/bar/wrap_scroll.c @@ -2,6 +2,7 @@ #include <strings.h> #include "sway/commands.h" #include "log.h" +#include "util.h" struct cmd_results *bar_cmd_wrap_scroll(int argc, char **argv) { struct cmd_results *error = NULL; @@ -11,17 +12,14 @@ struct cmd_results *bar_cmd_wrap_scroll(int argc, char **argv) { if (!config->current_bar) { return cmd_results_new(CMD_FAILURE, "wrap_scroll", "No bar defined."); } - if (strcasecmp("yes", argv[0]) == 0) { - config->current_bar->wrap_scroll = true; + config->current_bar->wrap_scroll = + parse_boolean(argv[0], config->current_bar->wrap_scroll); + if (config->current_bar->wrap_scroll) { wlr_log(WLR_DEBUG, "Enabling wrap scroll on bar: %s", - config->current_bar->id); - } else if (strcasecmp("no", argv[0]) == 0) { - config->current_bar->wrap_scroll = false; + config->current_bar->id); + } else { wlr_log(WLR_DEBUG, "Disabling wrap scroll on bar: %s", config->current_bar->id); - } else { - return cmd_results_new(CMD_INVALID, - "wrap_scroll", "Invalid value %s", argv[0]); } return cmd_results_new(CMD_SUCCESS, NULL, NULL); } |