diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-03-29 22:05:16 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-03-29 22:11:08 -0400 |
commit | 741424c4e7811c12d8cca28466f89bd61eaf3a75 (patch) | |
tree | 37af2aa063d42bf6ef3bc967bb1a5b6b679abbaf /sway/commands/bar | |
parent | Use statically allocated text buffer (diff) | |
download | sway-741424c4e7811c12d8cca28466f89bd61eaf3a75.tar.gz sway-741424c4e7811c12d8cca28466f89bd61eaf3a75.tar.zst sway-741424c4e7811c12d8cca28466f89bd61eaf3a75.zip |
Clean up imported bar commands
Diffstat (limited to 'sway/commands/bar')
23 files changed, 104 insertions, 136 deletions
diff --git a/sway/commands/bar/activate_button.c b/sway/commands/bar/activate_button.c index 0665d2a6..7310e7ec 100644 --- a/sway/commands/bar/activate_button.c +++ b/sway/commands/bar/activate_button.c | |||
@@ -3,7 +3,6 @@ | |||
3 | #include "log.h" | 3 | #include "log.h" |
4 | 4 | ||
5 | struct cmd_results *bar_cmd_activate_button(int argc, char **argv) { | 5 | struct cmd_results *bar_cmd_activate_button(int argc, char **argv) { |
6 | const char *cmd_name = "activate_button"; | ||
7 | // TODO TRAY | 6 | // TODO TRAY |
8 | return cmd_results_new(CMD_INVALID, cmd_name, "TODO TRAY"); | 7 | return cmd_results_new(CMD_INVALID, "activate_button", "TODO TRAY"); |
9 | } | 8 | } |
diff --git a/sway/commands/bar/binding_mode_indicator.c b/sway/commands/bar/binding_mode_indicator.c index e11e1033..3ba5f33f 100644 --- a/sway/commands/bar/binding_mode_indicator.c +++ b/sway/commands/bar/binding_mode_indicator.c | |||
@@ -5,23 +5,23 @@ | |||
5 | 5 | ||
6 | struct cmd_results *bar_cmd_binding_mode_indicator(int argc, char **argv) { | 6 | struct cmd_results *bar_cmd_binding_mode_indicator(int argc, char **argv) { |
7 | struct cmd_results *error = NULL; | 7 | struct cmd_results *error = NULL; |
8 | if ((error = checkarg(argc, "binding_mode_indicator", EXPECTED_EQUAL_TO, 1))) { | 8 | if ((error = checkarg(argc, |
9 | "binding_mode_indicator", EXPECTED_EQUAL_TO, 1))) { | ||
9 | return error; | 10 | return error; |
10 | } | 11 | } |
11 | |||
12 | if (!config->current_bar) { | 12 | if (!config->current_bar) { |
13 | return cmd_results_new(CMD_FAILURE, "binding_mode_indicator", "No bar defined."); | 13 | return cmd_results_new(CMD_FAILURE, |
14 | "binding_mode_indicator", "No bar defined."); | ||
14 | } | 15 | } |
15 | |||
16 | if (strcasecmp("yes", argv[0]) == 0) { | 16 | if (strcasecmp("yes", argv[0]) == 0) { |
17 | config->current_bar->binding_mode_indicator = true; | 17 | config->current_bar->binding_mode_indicator = true; |
18 | wlr_log(L_DEBUG, "Enabling binding mode indicator on bar: %s", config->current_bar->id); | 18 | wlr_log(L_DEBUG, "Enabling binding mode indicator on bar: %s", |
19 | config->current_bar->id); | ||
19 | } else if (strcasecmp("no", argv[0]) == 0) { | 20 | } else if (strcasecmp("no", argv[0]) == 0) { |
20 | config->current_bar->binding_mode_indicator = false; | 21 | config->current_bar->binding_mode_indicator = false; |
21 | wlr_log(L_DEBUG, "Disabling binding mode indicator on bar: %s", config->current_bar->id); | 22 | wlr_log(L_DEBUG, "Disabling binding mode indicator on bar: %s", |
22 | } else { | 23 | config->current_bar->id); |
23 | error = cmd_results_new(CMD_INVALID, "binding_mode_indicator", "Invalid value %s", argv[0]); | ||
24 | return error; | ||
25 | } | 24 | } |
26 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 25 | return cmd_results_new(CMD_INVALID, "binding_mode_indicator", |
26 | "Invalid value %s", argv[0]); | ||
27 | } | 27 | } |
diff --git a/sway/commands/bar/colors.c b/sway/commands/bar/colors.c index 8b3b0aac..17ba9b7c 100644 --- a/sway/commands/bar/colors.c +++ b/sway/commands/bar/colors.c | |||
@@ -1,47 +1,38 @@ | |||
1 | #include <string.h> | 1 | #include <string.h> |
2 | #include "sway/commands.h" | 2 | #include "sway/commands.h" |
3 | 3 | ||
4 | static struct cmd_results *parse_single_color(char **color, const char *cmd_name, int argc, char **argv) { | 4 | static struct cmd_results *parse_single_color(char **color, |
5 | const char *cmd_name, int argc, char **argv) { | ||
5 | struct cmd_results *error = NULL; | 6 | struct cmd_results *error = NULL; |
6 | if ((error = checkarg(argc, cmd_name, EXPECTED_EQUAL_TO, 1))) { | 7 | if ((error = checkarg(argc, cmd_name, EXPECTED_EQUAL_TO, 1))) { |
7 | return error; | 8 | return error; |
8 | } | 9 | } |
9 | 10 | if (!*color && !(*color = malloc(10))) { | |
10 | if (!*color) { | 11 | return NULL; |
11 | *color = malloc(10); | ||
12 | if (!*color) { | ||
13 | return cmd_results_new(CMD_FAILURE, cmd_name, "Unable to allocate color"); | ||
14 | } | ||
15 | } | 12 | } |
16 | |||
17 | error = add_color(cmd_name, *color, argv[0]); | 13 | error = add_color(cmd_name, *color, argv[0]); |
18 | if (error) { | 14 | if (error) { |
19 | return error; | 15 | return error; |
20 | } | 16 | } |
21 | |||
22 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 17 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
23 | } | 18 | } |
24 | 19 | ||
25 | static struct cmd_results *parse_three_colors(char ***colors, const char *cmd_name, int argc, char **argv) { | 20 | static struct cmd_results *parse_three_colors(char ***colors, |
21 | const char *cmd_name, int argc, char **argv) { | ||
26 | struct cmd_results *error = NULL; | 22 | struct cmd_results *error = NULL; |
27 | if (argc != 3) { | 23 | if (argc != 3) { |
28 | return cmd_results_new(CMD_INVALID, cmd_name, "Requires exactly three color values"); | 24 | return cmd_results_new(CMD_INVALID, |
25 | cmd_name, "Requires exactly three color values"); | ||
29 | } | 26 | } |
30 | 27 | for (size_t i = 0; i < 3; i++) { | |
31 | int i; | 28 | if (!*colors[i] && !(*(colors[i]) = malloc(10))) { |
32 | for (i = 0; i < 3; i++) { | 29 | return NULL; |
33 | if (!*colors[i]) { | ||
34 | *(colors[i]) = malloc(10); | ||
35 | if (!*(colors[i])) { | ||
36 | return cmd_results_new(CMD_FAILURE, cmd_name, "Unable to allocate color"); | ||
37 | } | ||
38 | } | 30 | } |
39 | error = add_color(cmd_name, *(colors[i]), argv[i]); | 31 | error = add_color(cmd_name, *(colors[i]), argv[i]); |
40 | if (error) { | 32 | if (error) { |
41 | return error; | 33 | return error; |
42 | } | 34 | } |
43 | } | 35 | } |
44 | |||
45 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 36 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
46 | } | 37 | } |
47 | 38 | ||
@@ -50,12 +41,10 @@ struct cmd_results *bar_cmd_colors(int argc, char **argv) { | |||
50 | if ((error = checkarg(argc, "colors", EXPECTED_EQUAL_TO, 1))) { | 41 | if ((error = checkarg(argc, "colors", EXPECTED_EQUAL_TO, 1))) { |
51 | return error; | 42 | return error; |
52 | } | 43 | } |
53 | |||
54 | if (strcmp("{", argv[0]) != 0) { | 44 | if (strcmp("{", argv[0]) != 0) { |
55 | return cmd_results_new(CMD_INVALID, "colors", | 45 | return cmd_results_new(CMD_INVALID, "colors", |
56 | "Expected '{' at the start of colors config definition."); | 46 | "Expected '{' at the start of colors config definition."); |
57 | } | 47 | } |
58 | |||
59 | return cmd_results_new(CMD_BLOCK_BAR_COLORS, NULL, NULL); | 48 | return cmd_results_new(CMD_BLOCK_BAR_COLORS, NULL, NULL); |
60 | } | 49 | } |
61 | 50 | ||
@@ -69,11 +58,13 @@ struct cmd_results *bar_colors_cmd_active_workspace(int argc, char **argv) { | |||
69 | } | 58 | } |
70 | 59 | ||
71 | struct cmd_results *bar_colors_cmd_background(int argc, char **argv) { | 60 | struct cmd_results *bar_colors_cmd_background(int argc, char **argv) { |
72 | return parse_single_color(&(config->current_bar->colors.background), "background", argc, argv); | 61 | return parse_single_color(&(config->current_bar->colors.background), |
62 | "background", argc, argv); | ||
73 | } | 63 | } |
74 | 64 | ||
75 | struct cmd_results *bar_colors_cmd_focused_background(int argc, char **argv) { | 65 | struct cmd_results *bar_colors_cmd_focused_background(int argc, char **argv) { |
76 | return parse_single_color(&(config->current_bar->colors.focused_background), "focused_background", argc, argv); | 66 | return parse_single_color(&(config->current_bar->colors.focused_background), |
67 | "focused_background", argc, argv); | ||
77 | } | 68 | } |
78 | 69 | ||
79 | struct cmd_results *bar_colors_cmd_binding_mode(int argc, char **argv) { | 70 | struct cmd_results *bar_colors_cmd_binding_mode(int argc, char **argv) { |
@@ -104,19 +95,23 @@ struct cmd_results *bar_colors_cmd_inactive_workspace(int argc, char **argv) { | |||
104 | } | 95 | } |
105 | 96 | ||
106 | struct cmd_results *bar_colors_cmd_separator(int argc, char **argv) { | 97 | struct cmd_results *bar_colors_cmd_separator(int argc, char **argv) { |
107 | return parse_single_color(&(config->current_bar->colors.separator), "separator", argc, argv); | 98 | return parse_single_color(&(config->current_bar->colors.separator), |
99 | "separator", argc, argv); | ||
108 | } | 100 | } |
109 | 101 | ||
110 | struct cmd_results *bar_colors_cmd_focused_separator(int argc, char **argv) { | 102 | struct cmd_results *bar_colors_cmd_focused_separator(int argc, char **argv) { |
111 | return parse_single_color(&(config->current_bar->colors.focused_separator), "focused_separator", argc, argv); | 103 | return parse_single_color(&(config->current_bar->colors.focused_separator), |
104 | "focused_separator", argc, argv); | ||
112 | } | 105 | } |
113 | 106 | ||
114 | struct cmd_results *bar_colors_cmd_statusline(int argc, char **argv) { | 107 | struct cmd_results *bar_colors_cmd_statusline(int argc, char **argv) { |
115 | return parse_single_color(&(config->current_bar->colors.statusline), "statusline", argc, argv); | 108 | return parse_single_color(&(config->current_bar->colors.statusline), |
109 | "statusline", argc, argv); | ||
116 | } | 110 | } |
117 | 111 | ||
118 | struct cmd_results *bar_colors_cmd_focused_statusline(int argc, char **argv) { | 112 | struct cmd_results *bar_colors_cmd_focused_statusline(int argc, char **argv) { |
119 | return parse_single_color(&(config->current_bar->colors.focused_separator), "focused_separator", argc, argv); | 113 | return parse_single_color(&(config->current_bar->colors.focused_separator), |
114 | "focused_separator", argc, argv); | ||
120 | } | 115 | } |
121 | 116 | ||
122 | struct cmd_results *bar_colors_cmd_urgent_workspace(int argc, char **argv) { | 117 | struct cmd_results *bar_colors_cmd_urgent_workspace(int argc, char **argv) { |
diff --git a/sway/commands/bar/context_button.c b/sway/commands/bar/context_button.c index e6d17f10..3b76885a 100644 --- a/sway/commands/bar/context_button.c +++ b/sway/commands/bar/context_button.c | |||
@@ -3,7 +3,6 @@ | |||
3 | #include "log.h" | 3 | #include "log.h" |
4 | 4 | ||
5 | struct cmd_results *bar_cmd_context_button(int argc, char **argv) { | 5 | struct cmd_results *bar_cmd_context_button(int argc, char **argv) { |
6 | const char *cmd_name = "context_button"; | ||
7 | // TODO TRAY | 6 | // TODO TRAY |
8 | return cmd_results_new(CMD_INVALID, cmd_name, "TODO TRAY"); | 7 | return cmd_results_new(CMD_INVALID, "context_button", "TODO TRAY"); |
9 | } | 8 | } |
diff --git a/sway/commands/bar/font.c b/sway/commands/bar/font.c index 6d7c533a..80b7a593 100644 --- a/sway/commands/bar/font.c +++ b/sway/commands/bar/font.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #define _POSIX_C_SOURCE 200809L | ||
1 | #include <string.h> | 2 | #include <string.h> |
2 | #include "sway/commands.h" | 3 | #include "sway/commands.h" |
3 | #include "log.h" | 4 | #include "log.h" |
@@ -8,19 +9,13 @@ struct cmd_results *bar_cmd_font(int argc, char **argv) { | |||
8 | if ((error = checkarg(argc, "font", EXPECTED_AT_LEAST, 1))) { | 9 | if ((error = checkarg(argc, "font", EXPECTED_AT_LEAST, 1))) { |
9 | return error; | 10 | return error; |
10 | } | 11 | } |
11 | |||
12 | if (!config->current_bar) { | 12 | if (!config->current_bar) { |
13 | return cmd_results_new(CMD_FAILURE, "font", "No bar defined."); | 13 | return cmd_results_new(CMD_FAILURE, "font", "No bar defined."); |
14 | } | 14 | } |
15 | |||
16 | char *font = join_args(argv, argc); | 15 | char *font = join_args(argv, argc); |
17 | free(config->current_bar->font); | 16 | free(config->current_bar->font); |
18 | if (strlen(font) > 6 && strncmp("pango:", font, 6) == 0) { | 17 | config->current_bar->font = strdup(font); |
19 | config->current_bar->font = font; | 18 | wlr_log(L_DEBUG, "Settings font '%s' for bar: %s", |
20 | } else { | 19 | config->current_bar->font, config->current_bar->id); |
21 | config->current_bar->font = font; | ||
22 | } | ||
23 | |||
24 | wlr_log(L_DEBUG, "Settings font '%s' for bar: %s", config->current_bar->font, config->current_bar->id); | ||
25 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 20 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
26 | } | 21 | } |
diff --git a/sway/commands/bar/height.c b/sway/commands/bar/height.c index ae0c7834..3160caed 100644 --- a/sway/commands/bar/height.c +++ b/sway/commands/bar/height.c | |||
@@ -8,14 +8,13 @@ struct cmd_results *bar_cmd_height(int argc, char **argv) { | |||
8 | if ((error = checkarg(argc, "height", EXPECTED_EQUAL_TO, 1))) { | 8 | if ((error = checkarg(argc, "height", EXPECTED_EQUAL_TO, 1))) { |
9 | return error; | 9 | return error; |
10 | } | 10 | } |
11 | |||
12 | int height = atoi(argv[0]); | 11 | int height = atoi(argv[0]); |
13 | if (height < 0) { | 12 | if (height < 0) { |
14 | return cmd_results_new(CMD_INVALID, "height", | 13 | return cmd_results_new(CMD_INVALID, "height", |
15 | "Invalid height value: %s", argv[0]); | 14 | "Invalid height value: %s", argv[0]); |
16 | } | 15 | } |
17 | |||
18 | config->current_bar->height = height; | 16 | config->current_bar->height = height; |
19 | wlr_log(L_DEBUG, "Setting bar height to %d on bar: %s", height, config->current_bar->id); | 17 | wlr_log(L_DEBUG, "Setting bar height to %d on bar: %s", |
18 | height, config->current_bar->id); | ||
20 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 19 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
21 | } | 20 | } |
diff --git a/sway/commands/bar/hidden_state.c b/sway/commands/bar/hidden_state.c index 245d0858..6641f184 100644 --- a/sway/commands/bar/hidden_state.c +++ b/sway/commands/bar/hidden_state.c | |||
@@ -23,7 +23,6 @@ static struct cmd_results *bar_set_hidden_state(struct bar_config *bar, | |||
23 | return cmd_results_new(CMD_INVALID, "hidden_state", | 23 | return cmd_results_new(CMD_INVALID, "hidden_state", |
24 | "Invalid value %s", hidden_state); | 24 | "Invalid value %s", hidden_state); |
25 | } | 25 | } |
26 | |||
27 | if (strcmp(old_state, bar->hidden_state) != 0) { | 26 | if (strcmp(old_state, bar->hidden_state) != 0) { |
28 | if (!config->reading) { | 27 | if (!config->reading) { |
29 | ipc_event_barconfig_update(bar); | 28 | ipc_event_barconfig_update(bar); |
@@ -31,7 +30,6 @@ static struct cmd_results *bar_set_hidden_state(struct bar_config *bar, | |||
31 | wlr_log(L_DEBUG, "Setting hidden_state: '%s' for bar: %s", | 30 | wlr_log(L_DEBUG, "Setting hidden_state: '%s' for bar: %s", |
32 | bar->hidden_state, bar->id); | 31 | bar->hidden_state, bar->id); |
33 | } | 32 | } |
34 | |||
35 | // free old mode | 33 | // free old mode |
36 | free(old_state); | 34 | free(old_state); |
37 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 35 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
@@ -45,14 +43,12 @@ struct cmd_results *bar_cmd_hidden_state(int argc, char **argv) { | |||
45 | if ((error = checkarg(argc, "hidden_state", EXPECTED_LESS_THAN, 3))) { | 43 | if ((error = checkarg(argc, "hidden_state", EXPECTED_LESS_THAN, 3))) { |
46 | return error; | 44 | return error; |
47 | } | 45 | } |
48 | |||
49 | if (config->reading && argc > 1) { | 46 | if (config->reading && argc > 1) { |
50 | return cmd_results_new(CMD_INVALID, "hidden_state", | 47 | return cmd_results_new(CMD_INVALID, "hidden_state", |
51 | "Unexpected value %s in config mode", argv[1]); | 48 | "Unexpected value %s in config mode", argv[1]); |
52 | } | 49 | } |
53 | 50 | ||
54 | const char *state = argv[0]; | 51 | const char *state = argv[0]; |
55 | |||
56 | if (config->reading) { | 52 | if (config->reading) { |
57 | return bar_set_hidden_state(config->current_bar, state); | 53 | return bar_set_hidden_state(config->current_bar, state); |
58 | } | 54 | } |
@@ -61,7 +57,6 @@ struct cmd_results *bar_cmd_hidden_state(int argc, char **argv) { | |||
61 | if (argc == 2) { | 57 | if (argc == 2) { |
62 | id = argv[1]; | 58 | id = argv[1]; |
63 | } | 59 | } |
64 | |||
65 | struct bar_config *bar; | 60 | struct bar_config *bar; |
66 | for (int i = 0; i < config->bars->length; ++i) { | 61 | for (int i = 0; i < config->bars->length; ++i) { |
67 | bar = config->bars->items[i]; | 62 | bar = config->bars->items[i]; |
diff --git a/sway/commands/bar/icon_theme.c b/sway/commands/bar/icon_theme.c index c6090b81..44cd3076 100644 --- a/sway/commands/bar/icon_theme.c +++ b/sway/commands/bar/icon_theme.c | |||
@@ -3,7 +3,6 @@ | |||
3 | #include "sway/commands.h" | 3 | #include "sway/commands.h" |
4 | 4 | ||
5 | struct cmd_results *bar_cmd_icon_theme(int argc, char **argv) { | 5 | struct cmd_results *bar_cmd_icon_theme(int argc, char **argv) { |
6 | const char *cmd_name = "tray_output"; | ||
7 | // TODO TRAY | 6 | // TODO TRAY |
8 | return cmd_results_new(CMD_INVALID, cmd_name, "TODO TRAY"); | 7 | return cmd_results_new(CMD_INVALID, "icon_theme", "TODO TRAY"); |
9 | } | 8 | } |
diff --git a/sway/commands/bar/id.c b/sway/commands/bar/id.c index d9e7f8df..c1e56f03 100644 --- a/sway/commands/bar/id.c +++ b/sway/commands/bar/id.c | |||
@@ -11,10 +11,8 @@ struct cmd_results *bar_cmd_id(int argc, char **argv) { | |||
11 | 11 | ||
12 | const char *name = argv[0]; | 12 | const char *name = argv[0]; |
13 | const char *oldname = config->current_bar->id; | 13 | const char *oldname = config->current_bar->id; |
14 | |||
15 | // check if id is used by a previously defined bar | 14 | // check if id is used by a previously defined bar |
16 | int i; | 15 | for (int i = 0; i < config->bars->length; ++i) { |
17 | for (i = 0; i < config->bars->length; ++i) { | ||
18 | struct bar_config *find = config->bars->items[i]; | 16 | struct bar_config *find = config->bars->items[i]; |
19 | if (strcmp(name, find->id) == 0 && config->current_bar != find) { | 17 | if (strcmp(name, find->id) == 0 && config->current_bar != find) { |
20 | return cmd_results_new(CMD_FAILURE, "id", | 18 | return cmd_results_new(CMD_FAILURE, "id", |
@@ -27,7 +25,6 @@ struct cmd_results *bar_cmd_id(int argc, char **argv) { | |||
27 | 25 | ||
28 | // free old bar id | 26 | // free old bar id |
29 | free(config->current_bar->id); | 27 | free(config->current_bar->id); |
30 | |||
31 | config->current_bar->id = strdup(name); | 28 | config->current_bar->id = strdup(name); |
32 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 29 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
33 | } | 30 | } |
diff --git a/sway/commands/bar/mode.c b/sway/commands/bar/mode.c index 7d346956..34bb0a4f 100644 --- a/sway/commands/bar/mode.c +++ b/sway/commands/bar/mode.c | |||
@@ -44,13 +44,12 @@ struct cmd_results *bar_cmd_mode(int argc, char **argv) { | |||
44 | if ((error = checkarg(argc, "mode", EXPECTED_LESS_THAN, 3))) { | 44 | if ((error = checkarg(argc, "mode", EXPECTED_LESS_THAN, 3))) { |
45 | return error; | 45 | return error; |
46 | } | 46 | } |
47 | |||
48 | if (config->reading && argc > 1) { | 47 | if (config->reading && argc > 1) { |
49 | return cmd_results_new(CMD_INVALID, "mode", "Unexpected value %s in config mode", argv[1]); | 48 | return cmd_results_new(CMD_INVALID, |
49 | "mode", "Unexpected value %s in config mode", argv[1]); | ||
50 | } | 50 | } |
51 | 51 | ||
52 | const char *mode = argv[0]; | 52 | const char *mode = argv[0]; |
53 | |||
54 | if (config->reading) { | 53 | if (config->reading) { |
55 | return bar_set_mode(config->current_bar, mode); | 54 | return bar_set_mode(config->current_bar, mode); |
56 | } | 55 | } |
@@ -60,19 +59,16 @@ struct cmd_results *bar_cmd_mode(int argc, char **argv) { | |||
60 | id = argv[1]; | 59 | id = argv[1]; |
61 | } | 60 | } |
62 | 61 | ||
63 | int i; | ||
64 | struct bar_config *bar; | 62 | struct bar_config *bar; |
65 | for (i = 0; i < config->bars->length; ++i) { | 63 | for (int i = 0; i < config->bars->length; ++i) { |
66 | bar = config->bars->items[i]; | 64 | bar = config->bars->items[i]; |
67 | if (id && strcmp(id, bar->id) == 0) { | 65 | if (id && strcmp(id, bar->id) == 0) { |
68 | return bar_set_mode(bar, mode); | 66 | return bar_set_mode(bar, mode); |
69 | } | 67 | } |
70 | |||
71 | error = bar_set_mode(bar, mode); | 68 | error = bar_set_mode(bar, mode); |
72 | if (error) { | 69 | if (error) { |
73 | return error; | 70 | return error; |
74 | } | 71 | } |
75 | } | 72 | } |
76 | |||
77 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 73 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
78 | } | 74 | } |
diff --git a/sway/commands/bar/modifier.c b/sway/commands/bar/modifier.c index 9a1f8b01..7ba4b125 100644 --- a/sway/commands/bar/modifier.c +++ b/sway/commands/bar/modifier.c | |||
@@ -15,7 +15,6 @@ struct cmd_results *bar_cmd_modifier(int argc, char **argv) { | |||
15 | } | 15 | } |
16 | 16 | ||
17 | uint32_t mod = 0; | 17 | uint32_t mod = 0; |
18 | |||
19 | list_t *split = split_string(argv[0], "+"); | 18 | list_t *split = split_string(argv[0], "+"); |
20 | for (int i = 0; i < split->length; ++i) { | 19 | for (int i = 0; i < split->length; ++i) { |
21 | uint32_t tmp_mod; | 20 | uint32_t tmp_mod; |
@@ -24,12 +23,13 @@ struct cmd_results *bar_cmd_modifier(int argc, char **argv) { | |||
24 | continue; | 23 | continue; |
25 | } else { | 24 | } else { |
26 | free_flat_list(split); | 25 | free_flat_list(split); |
27 | return cmd_results_new(CMD_INVALID, "modifier", "Unknown modifier '%s'", split->items[i]); | 26 | return cmd_results_new(CMD_INVALID, "modifier", |
27 | "Unknown modifier '%s'", split->items[i]); | ||
28 | } | 28 | } |
29 | } | 29 | } |
30 | free_flat_list(split); | 30 | free_flat_list(split); |
31 | |||
32 | config->current_bar->modifier = mod; | 31 | config->current_bar->modifier = mod; |
33 | wlr_log(L_DEBUG, "Show/Hide the bar when pressing '%s' in hide mode.", argv[0]); | 32 | wlr_log(L_DEBUG, |
33 | "Show/Hide the bar when pressing '%s' in hide mode.", argv[0]); | ||
34 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 34 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
35 | } | 35 | } |
diff --git a/sway/commands/bar/output.c b/sway/commands/bar/output.c index 034d9ca4..f7ca0aa4 100644 --- a/sway/commands/bar/output.c +++ b/sway/commands/bar/output.c | |||
@@ -1,4 +1,5 @@ | |||
1 | #define _XOPEN_SOURCE 500 | 1 | #define _XOPEN_SOURCE 500 |
2 | #include <stdbool.h> | ||
2 | #include <string.h> | 3 | #include <string.h> |
3 | #include "sway/commands.h" | 4 | #include "sway/commands.h" |
4 | #include "list.h" | 5 | #include "list.h" |
@@ -9,7 +10,6 @@ struct cmd_results *bar_cmd_output(int argc, char **argv) { | |||
9 | if ((error = checkarg(argc, "output", EXPECTED_EQUAL_TO, 1))) { | 10 | if ((error = checkarg(argc, "output", EXPECTED_EQUAL_TO, 1))) { |
10 | return error; | 11 | return error; |
11 | } | 12 | } |
12 | |||
13 | if (!config->current_bar) { | 13 | if (!config->current_bar) { |
14 | return cmd_results_new(CMD_FAILURE, "output", "No bar defined."); | 14 | return cmd_results_new(CMD_FAILURE, "output", "No bar defined."); |
15 | } | 15 | } |
@@ -21,21 +21,20 @@ struct cmd_results *bar_cmd_output(int argc, char **argv) { | |||
21 | config->current_bar->outputs = outputs; | 21 | config->current_bar->outputs = outputs; |
22 | } | 22 | } |
23 | 23 | ||
24 | int i; | 24 | bool add_output = true; |
25 | int add_output = 1; | ||
26 | if (strcmp("*", output) == 0) { | 25 | if (strcmp("*", output) == 0) { |
27 | // remove all previous defined outputs and replace with '*' | 26 | // remove all previous defined outputs and replace with '*' |
28 | for (i = 0; i < outputs->length; ++i) { | 27 | for (int i = 0; i < outputs->length; ++i) { |
29 | free(outputs->items[i]); | 28 | free(outputs->items[i]); |
30 | list_del(outputs, i); | 29 | list_del(outputs, i); |
31 | } | 30 | } |
32 | } else { | 31 | } else { |
33 | // only add output if not already defined with either the same | 32 | // only add output if not already defined with either the same |
34 | // name or as '*' | 33 | // name or as '*' |
35 | for (i = 0; i < outputs->length; ++i) { | 34 | for (int i = 0; i < outputs->length; ++i) { |
36 | const char *find = outputs->items[i]; | 35 | const char *find = outputs->items[i]; |
37 | if (strcmp("*", find) == 0 || strcmp(output, find) == 0) { | 36 | if (strcmp("*", find) == 0 || strcmp(output, find) == 0) { |
38 | add_output = 0; | 37 | add_output = false; |
39 | break; | 38 | break; |
40 | } | 39 | } |
41 | } | 40 | } |
@@ -43,8 +42,8 @@ struct cmd_results *bar_cmd_output(int argc, char **argv) { | |||
43 | 42 | ||
44 | if (add_output) { | 43 | if (add_output) { |
45 | list_add(outputs, strdup(output)); | 44 | list_add(outputs, strdup(output)); |
46 | wlr_log(L_DEBUG, "Adding bar: '%s' to output '%s'", config->current_bar->id, output); | 45 | wlr_log(L_DEBUG, "Adding bar: '%s' to output '%s'", |
46 | config->current_bar->id, output); | ||
47 | } | 47 | } |
48 | |||
49 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 48 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
50 | } | 49 | } |
diff --git a/sway/commands/bar/pango_markup.c b/sway/commands/bar/pango_markup.c index 34b85e98..480af724 100644 --- a/sway/commands/bar/pango_markup.c +++ b/sway/commands/bar/pango_markup.c | |||
@@ -8,19 +8,20 @@ struct cmd_results *bar_cmd_pango_markup(int argc, char **argv) { | |||
8 | if ((error = checkarg(argc, "pango_markup", EXPECTED_EQUAL_TO, 1))) { | 8 | if ((error = checkarg(argc, "pango_markup", EXPECTED_EQUAL_TO, 1))) { |
9 | return error; | 9 | return error; |
10 | } | 10 | } |
11 | |||
12 | if (!config->current_bar) { | 11 | if (!config->current_bar) { |
13 | return cmd_results_new(CMD_FAILURE, "pango_markup", "No bar defined."); | 12 | return cmd_results_new(CMD_FAILURE, "pango_markup", "No bar defined."); |
14 | } | 13 | } |
15 | |||
16 | if (strcasecmp("enabled", argv[0]) == 0) { | 14 | if (strcasecmp("enabled", argv[0]) == 0) { |
17 | config->current_bar->pango_markup = true; | 15 | config->current_bar->pango_markup = true; |
18 | wlr_log(L_DEBUG, "Enabling pango markup for bar: %s", config->current_bar->id); | 16 | wlr_log(L_DEBUG, "Enabling pango markup for bar: %s", |
17 | config->current_bar->id); | ||
19 | } else if (strcasecmp("disabled", argv[0]) == 0) { | 18 | } else if (strcasecmp("disabled", argv[0]) == 0) { |
20 | config->current_bar->pango_markup = false; | 19 | config->current_bar->pango_markup = false; |
21 | wlr_log(L_DEBUG, "Disabling pango markup for bar: %s", config->current_bar->id); | 20 | wlr_log(L_DEBUG, "Disabling pango markup for bar: %s", |
21 | config->current_bar->id); | ||
22 | } else { | 22 | } else { |
23 | error = cmd_results_new(CMD_INVALID, "pango_markup", "Invalid value %s", argv[0]); | 23 | error = cmd_results_new(CMD_INVALID, "pango_markup", |
24 | "Invalid value %s", argv[0]); | ||
24 | return error; | 25 | return error; |
25 | } | 26 | } |
26 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 27 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
diff --git a/sway/commands/bar/position.c b/sway/commands/bar/position.c index efa8c0bc..9c580483 100644 --- a/sway/commands/bar/position.c +++ b/sway/commands/bar/position.c | |||
@@ -9,11 +9,9 @@ struct cmd_results *bar_cmd_position(int argc, char **argv) { | |||
9 | if ((error = checkarg(argc, "position", EXPECTED_EQUAL_TO, 1))) { | 9 | if ((error = checkarg(argc, "position", EXPECTED_EQUAL_TO, 1))) { |
10 | return error; | 10 | return error; |
11 | } | 11 | } |
12 | |||
13 | if (!config->current_bar) { | 12 | if (!config->current_bar) { |
14 | return cmd_results_new(CMD_FAILURE, "position", "No bar defined."); | 13 | return cmd_results_new(CMD_FAILURE, "position", "No bar defined."); |
15 | } | 14 | } |
16 | |||
17 | char *valid[] = { "top", "bottom", "left", "right" }; | 15 | char *valid[] = { "top", "bottom", "left", "right" }; |
18 | for (size_t i = 0; i < sizeof(valid) / sizeof(valid[0]); ++i) { | 16 | for (size_t i = 0; i < sizeof(valid) / sizeof(valid[0]); ++i) { |
19 | if (strcasecmp(valid[i], argv[0]) == 0) { | 17 | if (strcasecmp(valid[i], argv[0]) == 0) { |
@@ -23,7 +21,6 @@ struct cmd_results *bar_cmd_position(int argc, char **argv) { | |||
23 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 21 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
24 | } | 22 | } |
25 | } | 23 | } |
26 | 24 | return cmd_results_new(CMD_INVALID, | |
27 | error = cmd_results_new(CMD_INVALID, "position", "Invalid value %s", argv[0]); | 25 | "position", "Invalid value %s", argv[0]); |
28 | return error; | ||
29 | } | 26 | } |
diff --git a/sway/commands/bar/secondary_button.c b/sway/commands/bar/secondary_button.c index 46d53e3f..449124cb 100644 --- a/sway/commands/bar/secondary_button.c +++ b/sway/commands/bar/secondary_button.c | |||
@@ -3,7 +3,6 @@ | |||
3 | #include "log.h" | 3 | #include "log.h" |
4 | 4 | ||
5 | struct cmd_results *bar_cmd_secondary_button(int argc, char **argv) { | 5 | struct cmd_results *bar_cmd_secondary_button(int argc, char **argv) { |
6 | const char *cmd_name = "secondary_button"; | ||
7 | // TODO TRAY | 6 | // TODO TRAY |
8 | return cmd_results_new(CMD_INVALID, cmd_name, "TODO TRAY"); | 7 | return cmd_results_new(CMD_INVALID, "secondary_button", "TODO TRAY"); |
9 | } | 8 | } |
diff --git a/sway/commands/bar/separator_symbol.c b/sway/commands/bar/separator_symbol.c index 7dc0956b..1e08df6d 100644 --- a/sway/commands/bar/separator_symbol.c +++ b/sway/commands/bar/separator_symbol.c | |||
@@ -8,14 +8,13 @@ struct cmd_results *bar_cmd_separator_symbol(int argc, char **argv) { | |||
8 | if ((error = checkarg(argc, "separator_symbol", EXPECTED_EQUAL_TO, 1))) { | 8 | if ((error = checkarg(argc, "separator_symbol", EXPECTED_EQUAL_TO, 1))) { |
9 | return error; | 9 | return error; |
10 | } | 10 | } |
11 | |||
12 | if (!config->current_bar) { | 11 | if (!config->current_bar) { |
13 | return cmd_results_new(CMD_FAILURE, "separator_symbol", "No bar defined."); | 12 | return cmd_results_new(CMD_FAILURE, |
13 | "separator_symbol", "No bar defined."); | ||
14 | } | 14 | } |
15 | |||
16 | free(config->current_bar->separator_symbol); | 15 | free(config->current_bar->separator_symbol); |
17 | config->current_bar->separator_symbol = strdup(argv[0]); | 16 | config->current_bar->separator_symbol = strdup(argv[0]); |
18 | wlr_log(L_DEBUG, "Settings separator_symbol '%s' for bar: %s", config->current_bar->separator_symbol, config->current_bar->id); | 17 | wlr_log(L_DEBUG, "Settings separator_symbol '%s' for bar: %s", |
19 | 18 | config->current_bar->separator_symbol, config->current_bar->id); | |
20 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 19 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
21 | } | 20 | } |
diff --git a/sway/commands/bar/status_command.c b/sway/commands/bar/status_command.c index 05377fcc..5e199cde 100644 --- a/sway/commands/bar/status_command.c +++ b/sway/commands/bar/status_command.c | |||
@@ -8,14 +8,13 @@ struct cmd_results *bar_cmd_status_command(int argc, char **argv) { | |||
8 | if ((error = checkarg(argc, "status_command", EXPECTED_AT_LEAST, 1))) { | 8 | if ((error = checkarg(argc, "status_command", EXPECTED_AT_LEAST, 1))) { |
9 | return error; | 9 | return error; |
10 | } | 10 | } |
11 | |||
12 | if (!config->current_bar) { | 11 | if (!config->current_bar) { |
13 | return cmd_results_new(CMD_FAILURE, "status_command", "No bar defined."); | 12 | return cmd_results_new(CMD_FAILURE, |
13 | "status_command", "No bar defined."); | ||
14 | } | 14 | } |
15 | |||
16 | free(config->current_bar->status_command); | 15 | free(config->current_bar->status_command); |
17 | config->current_bar->status_command = join_args(argv, argc); | 16 | config->current_bar->status_command = join_args(argv, argc); |
18 | wlr_log(L_DEBUG, "Feeding bar with status command: %s", config->current_bar->status_command); | 17 | wlr_log(L_DEBUG, "Feeding bar with status command: %s", |
19 | 18 | config->current_bar->status_command); | |
20 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 19 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
21 | } | 20 | } |
diff --git a/sway/commands/bar/strip_workspace_numbers.c b/sway/commands/bar/strip_workspace_numbers.c index 0558db8f..4f24a356 100644 --- a/sway/commands/bar/strip_workspace_numbers.c +++ b/sway/commands/bar/strip_workspace_numbers.c | |||
@@ -5,23 +5,25 @@ | |||
5 | 5 | ||
6 | struct cmd_results *bar_cmd_strip_workspace_numbers(int argc, char **argv) { | 6 | struct cmd_results *bar_cmd_strip_workspace_numbers(int argc, char **argv) { |
7 | struct cmd_results *error = NULL; | 7 | struct cmd_results *error = NULL; |
8 | if ((error = checkarg(argc, "strip_workspace_numbers", EXPECTED_EQUAL_TO, 1))) { | 8 | if ((error = checkarg(argc, |
9 | "strip_workspace_numbers", EXPECTED_EQUAL_TO, 1))) { | ||
9 | return error; | 10 | return error; |
10 | } | 11 | } |
11 | |||
12 | if (!config->current_bar) { | 12 | if (!config->current_bar) { |
13 | return cmd_results_new(CMD_FAILURE, "strip_workspace_numbers", "No bar defined."); | 13 | return cmd_results_new(CMD_FAILURE, |
14 | "strip_workspace_numbers", "No bar defined."); | ||
14 | } | 15 | } |
15 | |||
16 | if (strcasecmp("yes", argv[0]) == 0) { | 16 | if (strcasecmp("yes", argv[0]) == 0) { |
17 | config->current_bar->strip_workspace_numbers = true; | 17 | config->current_bar->strip_workspace_numbers = true; |
18 | wlr_log(L_DEBUG, "Stripping workspace numbers on bar: %s", config->current_bar->id); | 18 | wlr_log(L_DEBUG, "Stripping workspace numbers on bar: %s", |
19 | config->current_bar->id); | ||
19 | } else if (strcasecmp("no", argv[0]) == 0) { | 20 | } else if (strcasecmp("no", argv[0]) == 0) { |
20 | config->current_bar->strip_workspace_numbers = false; | 21 | config->current_bar->strip_workspace_numbers = false; |
21 | wlr_log(L_DEBUG, "Enabling workspace numbers on bar: %s", config->current_bar->id); | 22 | wlr_log(L_DEBUG, "Enabling workspace numbers on bar: %s", |
23 | config->current_bar->id); | ||
22 | } else { | 24 | } else { |
23 | error = cmd_results_new(CMD_INVALID, "strip_workspace_numbers", "Invalid value %s", argv[0]); | 25 | return cmd_results_new(CMD_INVALID, |
24 | return error; | 26 | "strip_workspace_numbers", "Invalid value %s", argv[0]); |
25 | } | 27 | } |
26 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 28 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
27 | } | 29 | } |
diff --git a/sway/commands/bar/swaybar_command.c b/sway/commands/bar/swaybar_command.c index 63d4f29a..520cdd11 100644 --- a/sway/commands/bar/swaybar_command.c +++ b/sway/commands/bar/swaybar_command.c | |||
@@ -8,14 +8,13 @@ struct cmd_results *bar_cmd_swaybar_command(int argc, char **argv) { | |||
8 | if ((error = checkarg(argc, "swaybar_command", EXPECTED_AT_LEAST, 1))) { | 8 | if ((error = checkarg(argc, "swaybar_command", EXPECTED_AT_LEAST, 1))) { |
9 | return error; | 9 | return error; |
10 | } | 10 | } |
11 | |||
12 | if (!config->current_bar) { | 11 | if (!config->current_bar) { |
13 | return cmd_results_new(CMD_FAILURE, "swaybar_command", "No bar defined."); | 12 | return cmd_results_new(CMD_FAILURE, |
13 | "swaybar_command", "No bar defined."); | ||
14 | } | 14 | } |
15 | |||
16 | free(config->current_bar->swaybar_command); | 15 | free(config->current_bar->swaybar_command); |
17 | config->current_bar->swaybar_command = join_args(argv, argc); | 16 | config->current_bar->swaybar_command = join_args(argv, argc); |
18 | wlr_log(L_DEBUG, "Using custom swaybar command: %s", config->current_bar->swaybar_command); | 17 | wlr_log(L_DEBUG, "Using custom swaybar command: %s", |
19 | 18 | config->current_bar->swaybar_command); | |
20 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 19 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
21 | } | 20 | } |
diff --git a/sway/commands/bar/tray_output.c b/sway/commands/bar/tray_output.c index 2d822146..6ab16731 100644 --- a/sway/commands/bar/tray_output.c +++ b/sway/commands/bar/tray_output.c | |||
@@ -3,7 +3,6 @@ | |||
3 | #include "sway/commands.h" | 3 | #include "sway/commands.h" |
4 | 4 | ||
5 | struct cmd_results *bar_cmd_tray_output(int argc, char **argv) { | 5 | struct cmd_results *bar_cmd_tray_output(int argc, char **argv) { |
6 | const char *cmd_name = "tray_output"; | ||
7 | // TODO TRAY | 6 | // TODO TRAY |
8 | return cmd_results_new(CMD_INVALID, cmd_name, "TODO TRAY"); | 7 | return cmd_results_new(CMD_INVALID, "tray_output", "TODO TRAY"); |
9 | } | 8 | } |
diff --git a/sway/commands/bar/tray_padding.c b/sway/commands/bar/tray_padding.c index 95b8ad3b..91c56f19 100644 --- a/sway/commands/bar/tray_padding.c +++ b/sway/commands/bar/tray_padding.c | |||
@@ -4,7 +4,6 @@ | |||
4 | #include "log.h" | 4 | #include "log.h" |
5 | 5 | ||
6 | struct cmd_results *bar_cmd_tray_padding(int argc, char **argv) { | 6 | struct cmd_results *bar_cmd_tray_padding(int argc, char **argv) { |
7 | const char *cmd_name = "tray_padding"; | ||
8 | // TODO TRAY | 7 | // TODO TRAY |
9 | return cmd_results_new(CMD_INVALID, cmd_name, "TODO TRAY"); | 8 | return cmd_results_new(CMD_INVALID, "tray_padding", "TODO TRAY"); |
10 | } | 9 | } |
diff --git a/sway/commands/bar/workspace_buttons.c b/sway/commands/bar/workspace_buttons.c index 1a617eb8..6edc3a0d 100644 --- a/sway/commands/bar/workspace_buttons.c +++ b/sway/commands/bar/workspace_buttons.c | |||
@@ -8,20 +8,21 @@ struct cmd_results *bar_cmd_workspace_buttons(int argc, char **argv) { | |||
8 | if ((error = checkarg(argc, "workspace_buttons", EXPECTED_EQUAL_TO, 1))) { | 8 | if ((error = checkarg(argc, "workspace_buttons", EXPECTED_EQUAL_TO, 1))) { |
9 | return error; | 9 | return error; |
10 | } | 10 | } |
11 | |||
12 | if (!config->current_bar) { | 11 | if (!config->current_bar) { |
13 | return cmd_results_new(CMD_FAILURE, "workspace_buttons", "No bar defined."); | 12 | return cmd_results_new(CMD_FAILURE, |
13 | "workspace_buttons", "No bar defined."); | ||
14 | } | 14 | } |
15 | |||
16 | if (strcasecmp("yes", argv[0]) == 0) { | 15 | if (strcasecmp("yes", argv[0]) == 0) { |
17 | config->current_bar->workspace_buttons = true; | 16 | config->current_bar->workspace_buttons = true; |
18 | wlr_log(L_DEBUG, "Enabling workspace buttons on bar: %s", config->current_bar->id); | 17 | wlr_log(L_DEBUG, "Enabling workspace buttons on bar: %s", |
18 | config->current_bar->id); | ||
19 | } else if (strcasecmp("no", argv[0]) == 0) { | 19 | } else if (strcasecmp("no", argv[0]) == 0) { |
20 | config->current_bar->workspace_buttons = false; | 20 | config->current_bar->workspace_buttons = false; |
21 | wlr_log(L_DEBUG, "Disabling workspace buttons on bar: %s", config->current_bar->id); | 21 | wlr_log(L_DEBUG, "Disabling workspace buttons on bar: %s", |
22 | config->current_bar->id); | ||
22 | } else { | 23 | } else { |
23 | error = cmd_results_new(CMD_INVALID, "workspace_buttons", "Invalid value %s", argv[0]); | 24 | return cmd_results_new(CMD_INVALID, "workspace_buttons", |
24 | return error; | 25 | "Invalid value %s", argv[0]); |
25 | } | 26 | } |
26 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 27 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
27 | } | 28 | } |
diff --git a/sway/commands/bar/wrap_scroll.c b/sway/commands/bar/wrap_scroll.c index c89dff5f..7386f82c 100644 --- a/sway/commands/bar/wrap_scroll.c +++ b/sway/commands/bar/wrap_scroll.c | |||
@@ -8,20 +8,20 @@ struct cmd_results *bar_cmd_wrap_scroll(int argc, char **argv) { | |||
8 | if ((error = checkarg(argc, "wrap_scroll", EXPECTED_EQUAL_TO, 1))) { | 8 | if ((error = checkarg(argc, "wrap_scroll", EXPECTED_EQUAL_TO, 1))) { |
9 | return error; | 9 | return error; |
10 | } | 10 | } |
11 | |||
12 | if (!config->current_bar) { | 11 | if (!config->current_bar) { |
13 | return cmd_results_new(CMD_FAILURE, "wrap_scroll", "No bar defined."); | 12 | return cmd_results_new(CMD_FAILURE, "wrap_scroll", "No bar defined."); |
14 | } | 13 | } |
15 | |||
16 | if (strcasecmp("yes", argv[0]) == 0) { | 14 | if (strcasecmp("yes", argv[0]) == 0) { |
17 | config->current_bar->wrap_scroll = true; | 15 | config->current_bar->wrap_scroll = true; |
18 | wlr_log(L_DEBUG, "Enabling wrap scroll on bar: %s", config->current_bar->id); | 16 | wlr_log(L_DEBUG, "Enabling wrap scroll on bar: %s", |
17 | config->current_bar->id); | ||
19 | } else if (strcasecmp("no", argv[0]) == 0) { | 18 | } else if (strcasecmp("no", argv[0]) == 0) { |
20 | config->current_bar->wrap_scroll = false; | 19 | config->current_bar->wrap_scroll = false; |
21 | wlr_log(L_DEBUG, "Disabling wrap scroll on bar: %s", config->current_bar->id); | 20 | wlr_log(L_DEBUG, "Disabling wrap scroll on bar: %s", |
21 | config->current_bar->id); | ||
22 | } else { | 22 | } else { |
23 | error = cmd_results_new(CMD_INVALID, "wrap_scroll", "Invalid value %s", argv[0]); | 23 | return cmd_results_new(CMD_INVALID, |
24 | return error; | 24 | "wrap_scroll", "Invalid value %s", argv[0]); |
25 | } | 25 | } |
26 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 26 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
27 | } | 27 | } |