diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-03-29 18:08:23 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2018-03-29 22:11:08 -0400 |
commit | 2e84f21ab786a5e31de836fda4e8bbd6de08d0ec (patch) | |
tree | 059730741e28a14cd1454fe1fd5d396beafa1696 | |
parent | Spawn swaybars when outputs are added (diff) | |
download | sway-2e84f21ab786a5e31de836fda4e8bbd6de08d0ec.tar.gz sway-2e84f21ab786a5e31de836fda4e8bbd6de08d0ec.tar.zst sway-2e84f21ab786a5e31de836fda4e8bbd6de08d0ec.zip |
Terminate swaybar when freeing bar config
-rw-r--r-- | sway/config/bar.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/sway/config/bar.c b/sway/config/bar.c index 5e02c01c..10abdef7 100644 --- a/sway/config/bar.c +++ b/sway/config/bar.c | |||
@@ -15,6 +15,16 @@ | |||
15 | #include "list.h" | 15 | #include "list.h" |
16 | #include "log.h" | 16 | #include "log.h" |
17 | 17 | ||
18 | static void terminate_swaybar(pid_t pid) { | ||
19 | int ret = kill(pid, SIGTERM); | ||
20 | if (ret != 0) { | ||
21 | wlr_log_errno(L_ERROR, "Unable to terminate swaybar %d", pid); | ||
22 | } else { | ||
23 | int status; | ||
24 | waitpid(pid, &status, 0); | ||
25 | } | ||
26 | } | ||
27 | |||
18 | void free_bar_config(struct bar_config *bar) { | 28 | void free_bar_config(struct bar_config *bar) { |
19 | if (!bar) { | 29 | if (!bar) { |
20 | return; | 30 | return; |
@@ -31,7 +41,7 @@ void free_bar_config(struct bar_config *bar) { | |||
31 | free_flat_list(bar->outputs); | 41 | free_flat_list(bar->outputs); |
32 | } | 42 | } |
33 | if (bar->pid != 0) { | 43 | if (bar->pid != 0) { |
34 | // TODO terminate_swaybar(bar->pid); | 44 | terminate_swaybar(bar->pid); |
35 | } | 45 | } |
36 | free(bar->colors.background); | 46 | free(bar->colors.background); |
37 | free(bar->colors.statusline); | 47 | free(bar->colors.statusline); |
@@ -191,16 +201,6 @@ void invoke_swaybar(struct bar_config *bar) { | |||
191 | close(filedes[1]); | 201 | close(filedes[1]); |
192 | } | 202 | } |
193 | 203 | ||
194 | static void terminate_swaybar(pid_t pid) { | ||
195 | int ret = kill(pid, SIGTERM); | ||
196 | if (ret != 0) { | ||
197 | wlr_log_errno(L_ERROR, "Unable to terminate swaybar %d", pid); | ||
198 | } else { | ||
199 | int status; | ||
200 | waitpid(pid, &status, 0); | ||
201 | } | ||
202 | } | ||
203 | |||
204 | static bool active_output(const char *name) { | 204 | static bool active_output(const char *name) { |
205 | swayc_t *cont = NULL; | 205 | swayc_t *cont = NULL; |
206 | for (int i = 0; i < root_container.children->length; ++i) { | 206 | for (int i = 0; i < root_container.children->length; ++i) { |