diff options
Diffstat (limited to 'swaybar')
-rw-r--r-- | swaybar/bar.c | 6 | ||||
-rw-r--r-- | swaybar/ipc.c | 6 | ||||
-rw-r--r-- | swaybar/main.c | 8 |
3 files changed, 9 insertions, 11 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c index 5b7fea71..f2dab738 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c | |||
@@ -517,14 +517,13 @@ static void set_bar_dirty(struct swaybar *bar) { | |||
517 | } | 517 | } |
518 | } | 518 | } |
519 | 519 | ||
520 | bool bar_setup(struct swaybar *bar, | 520 | bool bar_setup(struct swaybar *bar, const char *socket_path) { |
521 | const char *socket_path, const char *bar_id) { | ||
522 | bar_init(bar); | 521 | bar_init(bar); |
523 | init_event_loop(); | 522 | init_event_loop(); |
524 | 523 | ||
525 | bar->ipc_socketfd = ipc_open_socket(socket_path); | 524 | bar->ipc_socketfd = ipc_open_socket(socket_path); |
526 | bar->ipc_event_socketfd = ipc_open_socket(socket_path); | 525 | bar->ipc_event_socketfd = ipc_open_socket(socket_path); |
527 | if (!ipc_initialize(bar, bar_id)) { | 526 | if (!ipc_initialize(bar)) { |
528 | return false; | 527 | return false; |
529 | } | 528 | } |
530 | if (bar->config->status_command) { | 529 | if (bar->config->status_command) { |
@@ -625,4 +624,5 @@ void bar_teardown(struct swaybar *bar) { | |||
625 | if (bar->status) { | 624 | if (bar->status) { |
626 | status_line_free(bar->status); | 625 | status_line_free(bar->status); |
627 | } | 626 | } |
627 | free(bar->id); | ||
628 | } | 628 | } |
diff --git a/swaybar/ipc.c b/swaybar/ipc.c index a67814c1..84046ab5 100644 --- a/swaybar/ipc.c +++ b/swaybar/ipc.c | |||
@@ -345,10 +345,10 @@ void ipc_execute_binding(struct swaybar *bar, struct swaybar_binding *bind) { | |||
345 | IPC_COMMAND, bind->command, &len)); | 345 | IPC_COMMAND, bind->command, &len)); |
346 | } | 346 | } |
347 | 347 | ||
348 | bool ipc_initialize(struct swaybar *bar, const char *bar_id) { | 348 | bool ipc_initialize(struct swaybar *bar) { |
349 | uint32_t len = strlen(bar_id); | 349 | uint32_t len = strlen(bar->id); |
350 | char *res = ipc_single_command(bar->ipc_socketfd, | 350 | char *res = ipc_single_command(bar->ipc_socketfd, |
351 | IPC_GET_BAR_CONFIG, bar_id, &len); | 351 | IPC_GET_BAR_CONFIG, bar->id, &len); |
352 | if (!ipc_parse_config(bar->config, res)) { | 352 | if (!ipc_parse_config(bar->config, res)) { |
353 | free(res); | 353 | free(res); |
354 | return false; | 354 | return false; |
diff --git a/swaybar/main.c b/swaybar/main.c index db204f4a..2672abef 100644 --- a/swaybar/main.c +++ b/swaybar/main.c | |||
@@ -22,7 +22,6 @@ void sway_terminate(int code) { | |||
22 | 22 | ||
23 | int main(int argc, char **argv) { | 23 | int main(int argc, char **argv) { |
24 | char *socket_path = NULL; | 24 | char *socket_path = NULL; |
25 | char *bar_id = NULL; | ||
26 | bool debug = false; | 25 | bool debug = false; |
27 | 26 | ||
28 | static struct option long_options[] = { | 27 | static struct option long_options[] = { |
@@ -59,7 +58,7 @@ int main(int argc, char **argv) { | |||
59 | socket_path = strdup(optarg); | 58 | socket_path = strdup(optarg); |
60 | break; | 59 | break; |
61 | case 'b': // Type | 60 | case 'b': // Type |
62 | bar_id = strdup(optarg); | 61 | swaybar.id = strdup(optarg); |
63 | break; | 62 | break; |
64 | case 'v': | 63 | case 'v': |
65 | fprintf(stdout, "swaybar version " SWAY_VERSION "\n"); | 64 | fprintf(stdout, "swaybar version " SWAY_VERSION "\n"); |
@@ -80,7 +79,7 @@ int main(int argc, char **argv) { | |||
80 | wlr_log_init(WLR_ERROR, NULL); | 79 | wlr_log_init(WLR_ERROR, NULL); |
81 | } | 80 | } |
82 | 81 | ||
83 | if (!bar_id) { | 82 | if (!swaybar.id) { |
84 | wlr_log(WLR_ERROR, "No bar_id passed. " | 83 | wlr_log(WLR_ERROR, "No bar_id passed. " |
85 | "Provide --bar_id or let sway start swaybar"); | 84 | "Provide --bar_id or let sway start swaybar"); |
86 | return 1; | 85 | return 1; |
@@ -96,13 +95,12 @@ int main(int argc, char **argv) { | |||
96 | 95 | ||
97 | signal(SIGTERM, sig_handler); | 96 | signal(SIGTERM, sig_handler); |
98 | 97 | ||
99 | if (!bar_setup(&swaybar, socket_path, bar_id)) { | 98 | if (!bar_setup(&swaybar, socket_path)) { |
100 | free(socket_path); | 99 | free(socket_path); |
101 | return 1; | 100 | return 1; |
102 | } | 101 | } |
103 | 102 | ||
104 | free(socket_path); | 103 | free(socket_path); |
105 | free(bar_id); | ||
106 | 104 | ||
107 | bar_run(&swaybar); | 105 | bar_run(&swaybar); |
108 | bar_teardown(&swaybar); | 106 | bar_teardown(&swaybar); |