summaryrefslogtreecommitdiffstats
path: root/sway/commands/bar/output.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/bar/output.c')
-rw-r--r--sway/commands/bar/output.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/sway/commands/bar/output.c b/sway/commands/bar/output.c
index a5710bc0..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 sway_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}