aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sway/commands/bar/binding_mode_indicator.c12
-rw-r--r--sway/commands/bar/pango_markup.c13
-rw-r--r--sway/commands/bar/workspace_buttons.c12
-rw-r--r--sway/commands/bar/wrap_scroll.c14
-rw-r--r--sway/commands/floating.c14
-rw-r--r--sway/commands/input/xkb_capslock.c10
-rw-r--r--sway/commands/input/xkb_numlock.c10
-rw-r--r--sway/commands/seat/fallback.c13
-rw-r--r--sway/commands/smart_gaps.c10
-rw-r--r--sway/commands/sticky.c17
-rw-r--r--sway/commands/ws_auto_back_and_forth.c4
11 files changed, 39 insertions, 90 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 @@
2#include <strings.h> 2#include <strings.h>
3#include "sway/commands.h" 3#include "sway/commands.h"
4#include "log.h" 4#include "log.h"
5#include "util.h"
5 6
6struct cmd_results *bar_cmd_binding_mode_indicator(int argc, char **argv) { 7struct cmd_results *bar_cmd_binding_mode_indicator(int argc, char **argv) {
7 struct cmd_results *error = NULL; 8 struct cmd_results *error = NULL;
@@ -13,17 +14,14 @@ struct cmd_results *bar_cmd_binding_mode_indicator(int argc, char **argv) {
13 return cmd_results_new(CMD_FAILURE, 14 return cmd_results_new(CMD_FAILURE,
14 "binding_mode_indicator", "No bar defined."); 15 "binding_mode_indicator", "No bar defined.");
15 } 16 }
16 if (strcasecmp("yes", argv[0]) == 0) { 17 config->current_bar->binding_mode_indicator =
17 config->current_bar->binding_mode_indicator = true; 18 parse_boolean(argv[0], config->current_bar->binding_mode_indicator);
19 if (config->current_bar->binding_mode_indicator) {
18 wlr_log(WLR_DEBUG, "Enabling binding mode indicator on bar: %s", 20 wlr_log(WLR_DEBUG, "Enabling binding mode indicator on bar: %s",
19 config->current_bar->id); 21 config->current_bar->id);
20 } else if (strcasecmp("no", argv[0]) == 0) { 22 } else {
21 config->current_bar->binding_mode_indicator = false;
22 wlr_log(WLR_DEBUG, "Disabling binding mode indicator on bar: %s", 23 wlr_log(WLR_DEBUG, "Disabling binding mode indicator on bar: %s",
23 config->current_bar->id); 24 config->current_bar->id);
24 } else {
25 return cmd_results_new(CMD_INVALID, "binding_mode_indicator",
26 "Invalid value %s", argv[0]);
27 } 25 }
28 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 26 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
29} 27}
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 @@
2#include <strings.h> 2#include <strings.h>
3#include "sway/commands.h" 3#include "sway/commands.h"
4#include "log.h" 4#include "log.h"
5#include "util.h"
5 6
6struct cmd_results *bar_cmd_pango_markup(int argc, char **argv) { 7struct cmd_results *bar_cmd_pango_markup(int argc, char **argv) {
7 struct cmd_results *error = NULL; 8 struct cmd_results *error = NULL;
@@ -11,18 +12,14 @@ struct cmd_results *bar_cmd_pango_markup(int argc, char **argv) {
11 if (!config->current_bar) { 12 if (!config->current_bar) {
12 return cmd_results_new(CMD_FAILURE, "pango_markup", "No bar defined."); 13 return cmd_results_new(CMD_FAILURE, "pango_markup", "No bar defined.");
13 } 14 }
14 if (strcasecmp("enabled", argv[0]) == 0) { 15 config->current_bar->pango_markup
15 config->current_bar->pango_markup = true; 16 = parse_boolean(argv[0], config->current_bar->pango_markup);
17 if (config->current_bar->pango_markup) {
16 wlr_log(WLR_DEBUG, "Enabling pango markup for bar: %s", 18 wlr_log(WLR_DEBUG, "Enabling pango markup for bar: %s",
17 config->current_bar->id); 19 config->current_bar->id);
18 } else if (strcasecmp("disabled", argv[0]) == 0) { 20 } else {
19 config->current_bar->pango_markup = false;
20 wlr_log(WLR_DEBUG, "Disabling pango markup for bar: %s", 21 wlr_log(WLR_DEBUG, "Disabling pango markup for bar: %s",
21 config->current_bar->id); 22 config->current_bar->id);
22 } else {
23 error = cmd_results_new(CMD_INVALID, "pango_markup",
24 "Invalid value %s", argv[0]);
25 return error;
26 } 23 }
27 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 24 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
28} 25}
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 @@
2#include <strings.h> 2#include <strings.h>
3#include "sway/commands.h" 3#include "sway/commands.h"
4#include "log.h" 4#include "log.h"
5#include "util.h"
5 6
6struct cmd_results *bar_cmd_workspace_buttons(int argc, char **argv) { 7struct cmd_results *bar_cmd_workspace_buttons(int argc, char **argv) {
7 struct cmd_results *error = NULL; 8 struct cmd_results *error = NULL;
@@ -12,17 +13,14 @@ struct cmd_results *bar_cmd_workspace_buttons(int argc, char **argv) {
12 return cmd_results_new(CMD_FAILURE, 13 return cmd_results_new(CMD_FAILURE,
13 "workspace_buttons", "No bar defined."); 14 "workspace_buttons", "No bar defined.");
14 } 15 }
15 if (strcasecmp("yes", argv[0]) == 0) { 16 config->current_bar->workspace_buttons =
16 config->current_bar->workspace_buttons = true; 17 parse_boolean(argv[0], config->current_bar->workspace_buttons);
18 if (config->current_bar->workspace_buttons) {
17 wlr_log(WLR_DEBUG, "Enabling workspace buttons on bar: %s", 19 wlr_log(WLR_DEBUG, "Enabling workspace buttons on bar: %s",
18 config->current_bar->id); 20 config->current_bar->id);
19 } else if (strcasecmp("no", argv[0]) == 0) { 21 } else {
20 config->current_bar->workspace_buttons = false;
21 wlr_log(WLR_DEBUG, "Disabling workspace buttons on bar: %s", 22 wlr_log(WLR_DEBUG, "Disabling workspace buttons on bar: %s",
22 config->current_bar->id); 23 config->current_bar->id);
23 } else {
24 return cmd_results_new(CMD_INVALID, "workspace_buttons",
25 "Invalid value %s", argv[0]);
26 } 24 }
27 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 25 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
28} 26}
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 @@
2#include <strings.h> 2#include <strings.h>
3#include "sway/commands.h" 3#include "sway/commands.h"
4#include "log.h" 4#include "log.h"
5#include "util.h"
5 6
6struct cmd_results *bar_cmd_wrap_scroll(int argc, char **argv) { 7struct cmd_results *bar_cmd_wrap_scroll(int argc, char **argv) {
7 struct cmd_results *error = NULL; 8 struct cmd_results *error = NULL;
@@ -11,17 +12,14 @@ struct cmd_results *bar_cmd_wrap_scroll(int argc, char **argv) {
11 if (!config->current_bar) { 12 if (!config->current_bar) {
12 return cmd_results_new(CMD_FAILURE, "wrap_scroll", "No bar defined."); 13 return cmd_results_new(CMD_FAILURE, "wrap_scroll", "No bar defined.");
13 } 14 }
14 if (strcasecmp("yes", argv[0]) == 0) { 15 config->current_bar->wrap_scroll =
15 config->current_bar->wrap_scroll = true; 16 parse_boolean(argv[0], config->current_bar->wrap_scroll);
17 if (config->current_bar->wrap_scroll) {
16 wlr_log(WLR_DEBUG, "Enabling wrap scroll on bar: %s", 18 wlr_log(WLR_DEBUG, "Enabling wrap scroll on bar: %s",
17 config->current_bar->id); 19 config->current_bar->id);
18 } else if (strcasecmp("no", argv[0]) == 0) { 20 } else {
19 config->current_bar->wrap_scroll = false;
20 wlr_log(WLR_DEBUG, "Disabling wrap scroll on bar: %s", 21 wlr_log(WLR_DEBUG, "Disabling wrap scroll on bar: %s",
21 config->current_bar->id); 22 config->current_bar->id);
22 } else {
23 return cmd_results_new(CMD_INVALID,
24 "wrap_scroll", "Invalid value %s", argv[0]);
25 } 23 }
26 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 24 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
27} 25}
diff --git a/sway/commands/floating.c b/sway/commands/floating.c
index 81bb86f8..4b82921c 100644
--- a/sway/commands/floating.c
+++ b/sway/commands/floating.c
@@ -9,6 +9,7 @@
9#include "sway/tree/view.h" 9#include "sway/tree/view.h"
10#include "sway/tree/workspace.h" 10#include "sway/tree/workspace.h"
11#include "list.h" 11#include "list.h"
12#include "util.h"
12 13
13struct cmd_results *cmd_floating(int argc, char **argv) { 14struct cmd_results *cmd_floating(int argc, char **argv) {
14 struct cmd_results *error = NULL; 15 struct cmd_results *error = NULL;
@@ -40,17 +41,8 @@ struct cmd_results *cmd_floating(int argc, char **argv) {
40 } 41 }
41 } 42 }
42 43
43 bool wants_floating; 44 bool wants_floating =
44 if (strcasecmp(argv[0], "enable") == 0) { 45 parse_boolean(argv[0], container_is_floating(container));
45 wants_floating = true;
46 } else if (strcasecmp(argv[0], "disable") == 0) {
47 wants_floating = false;
48 } else if (strcasecmp(argv[0], "toggle") == 0) {
49 wants_floating = !container_is_floating(container);
50 } else {
51 return cmd_results_new(CMD_FAILURE, "floating",
52 "Expected 'floating <enable|disable|toggle>'");
53 }
54 46
55 container_set_floating(container, wants_floating); 47 container_set_floating(container, wants_floating);
56 48
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 @@
3#include "sway/config.h" 3#include "sway/config.h"
4#include "sway/commands.h" 4#include "sway/commands.h"
5#include "sway/input/input-manager.h" 5#include "sway/input/input-manager.h"
6#include "util.h"
6 7
7struct cmd_results *input_cmd_xkb_capslock(int argc, char **argv) { 8struct cmd_results *input_cmd_xkb_capslock(int argc, char **argv) {
8 struct cmd_results *error = NULL; 9 struct cmd_results *error = NULL;
@@ -15,14 +16,7 @@ struct cmd_results *input_cmd_xkb_capslock(int argc, char **argv) {
15 "No input device defined."); 16 "No input device defined.");
16 } 17 }
17 18
18 if (strcasecmp(argv[0], "enabled") == 0) { 19 ic->xkb_capslock = parse_boolean(argv[0], false);
19 ic->xkb_capslock = 1;
20 } else if (strcasecmp(argv[0], "disabled") == 0) {
21 ic->xkb_capslock = 0;
22 } else {
23 return cmd_results_new(CMD_INVALID, "xkb_capslock",
24 "Expected 'xkb_capslock <enabled|disabled>'");
25 }
26 20
27 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 21 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
28} 22}
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 @@
3#include "sway/config.h" 3#include "sway/config.h"
4#include "sway/commands.h" 4#include "sway/commands.h"
5#include "sway/input/input-manager.h" 5#include "sway/input/input-manager.h"
6#include "util.h"
6 7
7struct cmd_results *input_cmd_xkb_numlock(int argc, char **argv) { 8struct cmd_results *input_cmd_xkb_numlock(int argc, char **argv) {
8 struct cmd_results *error = NULL; 9 struct cmd_results *error = NULL;
@@ -15,14 +16,7 @@ struct cmd_results *input_cmd_xkb_numlock(int argc, char **argv) {
15 "No input device defined."); 16 "No input device defined.");
16 } 17 }
17 18
18 if (strcasecmp(argv[0], "enabled") == 0) { 19 ic->xkb_numlock = parse_boolean(argv[0], false);
19 ic->xkb_numlock = 1;
20 } else if (strcasecmp(argv[0], "disabled") == 0) {
21 ic->xkb_numlock = 0;
22 } else {
23 return cmd_results_new(CMD_INVALID, "xkb_numlock",
24 "Expected 'xkb_numlock <enabled|disabled>'");
25 }
26 20
27 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 21 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
28} 22}
diff --git a/sway/commands/seat/fallback.c b/sway/commands/seat/fallback.c
index 11f5a08c..a0ddf3ef 100644
--- a/sway/commands/seat/fallback.c
+++ b/sway/commands/seat/fallback.c
@@ -3,6 +3,7 @@
3#include "sway/config.h" 3#include "sway/config.h"
4#include "sway/commands.h" 4#include "sway/commands.h"
5#include "sway/input/input-manager.h" 5#include "sway/input/input-manager.h"
6#include "util.h"
6 7
7struct cmd_results *seat_cmd_fallback(int argc, char **argv) { 8struct cmd_results *seat_cmd_fallback(int argc, char **argv) {
8 struct cmd_results *error = NULL; 9 struct cmd_results *error = NULL;
@@ -16,16 +17,8 @@ struct cmd_results *seat_cmd_fallback(int argc, char **argv) {
16 } 17 }
17 struct seat_config *new_config = 18 struct seat_config *new_config =
18 new_seat_config(current_seat_config->name); 19 new_seat_config(current_seat_config->name);
19 20
20 if (strcasecmp(argv[0], "true") == 0) { 21 new_config->fallback = parse_boolean(argv[0], false);
21 new_config->fallback = 1;
22 } else if (strcasecmp(argv[0], "false") == 0) {
23 new_config->fallback = 0;
24 } else {
25 free_seat_config(new_config);
26 return cmd_results_new(CMD_INVALID, "fallback",
27 "Expected 'fallback <true|false>'");
28 }
29 22
30 if (!config->validating) { 23 if (!config->validating) {
31 apply_seat_config(new_config); 24 apply_seat_config(new_config);
diff --git a/sway/commands/smart_gaps.c b/sway/commands/smart_gaps.c
index 273905df..f14b6760 100644
--- a/sway/commands/smart_gaps.c
+++ b/sway/commands/smart_gaps.c
@@ -6,6 +6,7 @@
6#include "sway/tree/container.h" 6#include "sway/tree/container.h"
7#include "log.h" 7#include "log.h"
8#include "stringop.h" 8#include "stringop.h"
9#include "util.h"
9 10
10struct cmd_results *cmd_smart_gaps(int argc, char **argv) { 11struct cmd_results *cmd_smart_gaps(int argc, char **argv) {
11 struct cmd_results *error = checkarg(argc, "smart_gaps", EXPECTED_AT_LEAST, 1); 12 struct cmd_results *error = checkarg(argc, "smart_gaps", EXPECTED_AT_LEAST, 1);
@@ -14,14 +15,7 @@ struct cmd_results *cmd_smart_gaps(int argc, char **argv) {
14 return error; 15 return error;
15 } 16 }
16 17
17 if (strcmp(argv[0], "on") == 0) { 18 config->smart_gaps = parse_boolean(argv[0], config->smart_gaps);
18 config->smart_gaps = true;
19 } else if (strcmp(argv[0], "off") == 0) {
20 config->smart_gaps = false;
21 } else {
22 return cmd_results_new(CMD_INVALID, "smart_gaps",
23 "Expected 'smart_gaps <on|off>' ");
24 }
25 19
26 arrange_root(); 20 arrange_root();
27 21
diff --git a/sway/commands/sticky.c b/sway/commands/sticky.c
index f18322b7..7cd358a4 100644
--- a/sway/commands/sticky.c
+++ b/sway/commands/sticky.c
@@ -9,6 +9,7 @@
9#include "sway/tree/view.h" 9#include "sway/tree/view.h"
10#include "sway/tree/workspace.h" 10#include "sway/tree/workspace.h"
11#include "list.h" 11#include "list.h"
12#include "util.h"
12 13
13struct cmd_results *cmd_sticky(int argc, char **argv) { 14struct cmd_results *cmd_sticky(int argc, char **argv) {
14 struct cmd_results *error = NULL; 15 struct cmd_results *error = NULL;
@@ -26,21 +27,9 @@ struct cmd_results *cmd_sticky(int argc, char **argv) {
26 "Can't set sticky on a tiled container"); 27 "Can't set sticky on a tiled container");
27 } 28 }
28 29
29 bool wants_sticky; 30 container->is_sticky = parse_boolean(argv[0], container->is_sticky);
30 if (strcasecmp(argv[0], "enable") == 0) {
31 wants_sticky = true;
32 } else if (strcasecmp(argv[0], "disable") == 0) {
33 wants_sticky = false;
34 } else if (strcasecmp(argv[0], "toggle") == 0) {
35 wants_sticky = !container->is_sticky;
36 } else {
37 return cmd_results_new(CMD_FAILURE, "sticky",
38 "Expected 'sticky <enable|disable|toggle>'");
39 }
40
41 container->is_sticky = wants_sticky;
42 31
43 if (wants_sticky) { 32 if (container->is_sticky) {
44 // move container to active workspace 33 // move container to active workspace
45 struct sway_workspace *active_workspace = 34 struct sway_workspace *active_workspace =
46 output_get_active_workspace(container->workspace->output); 35 output_get_active_workspace(container->workspace->output);
diff --git a/sway/commands/ws_auto_back_and_forth.c b/sway/commands/ws_auto_back_and_forth.c
index 2485db35..3449d4cc 100644
--- a/sway/commands/ws_auto_back_and_forth.c
+++ b/sway/commands/ws_auto_back_and_forth.c
@@ -1,12 +1,14 @@
1#include <string.h> 1#include <string.h>
2#include <strings.h> 2#include <strings.h>
3#include "sway/commands.h" 3#include "sway/commands.h"
4#include "util.h"
4 5
5struct cmd_results *cmd_ws_auto_back_and_forth(int argc, char **argv) { 6struct cmd_results *cmd_ws_auto_back_and_forth(int argc, char **argv) {
6 struct cmd_results *error = NULL; 7 struct cmd_results *error = NULL;
7 if ((error = checkarg(argc, "workspace_auto_back_and_forth", EXPECTED_EQUAL_TO, 1))) { 8 if ((error = checkarg(argc, "workspace_auto_back_and_forth", EXPECTED_EQUAL_TO, 1))) {
8 return error; 9 return error;
9 } 10 }
10 config->auto_back_and_forth = !strcasecmp(argv[0], "yes"); 11 config->auto_back_and_forth =
12 !parse_boolean(argv[0], config->auto_back_and_forth);
11 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 13 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
12} 14}