aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
Diffstat (limited to 'sway')
-rw-r--r--sway/commands/bar/bindsym.c6
-rw-r--r--sway/config/bar.c9
2 files changed, 6 insertions, 9 deletions
diff --git a/sway/commands/bar/bindsym.c b/sway/commands/bar/bindsym.c
index b0df9eff..4eea3e6a 100644
--- a/sway/commands/bar/bindsym.c
+++ b/sway/commands/bar/bindsym.c
@@ -33,12 +33,12 @@ struct cmd_results *bar_cmd_bindsym(int argc, char **argv) {
binding->button = 0;
if (strncasecmp(argv[0], "button", strlen("button")) == 0 &&
strlen(argv[0]) == strlen("button0")) {
- binding->button = argv[0][strlen("button")] - '1' + 1;
+ binding->button = argv[0][strlen("button")] - '0';
}
- if (binding->button == 0) {
+ if (binding->button < 1 || binding->button > 9) {
free_bar_binding(binding);
return cmd_results_new(CMD_FAILURE, "bar bindsym",
- "Only button<n> is supported");
+ "Only button<1-9> is supported");
}
binding->command = join_args(argv + 1, argc - 1);
diff --git a/sway/config/bar.c b/sway/config/bar.c
index f84407c9..c6899f57 100644
--- a/sway/config/bar.c
+++ b/sway/config/bar.c
@@ -32,9 +32,7 @@ void free_bar_binding(struct bar_binding *binding) {
if (!binding) {
return;
}
- if (binding->command) {
- free(binding->command);
- }
+ free(binding->command);
free(binding);
}
@@ -49,9 +47,8 @@ void free_bar_config(struct bar_config *bar) {
free(bar->status_command);
free(bar->font);
free(bar->separator_symbol);
- while (bar->bindings->length) {
- struct bar_binding *binding = bar->bindings->items[0];
- list_del(bar->bindings, 0);
+ for (int i = 0; i < bar->bindings->length; i++) {
+ struct bar_binding *binding = bar->bindings->items[i];
free_bar_binding(binding);
}
list_free(bar->bindings);