From 2e84f21ab786a5e31de836fda4e8bbd6de08d0ec Mon Sep 17 00:00:00 2001
From: Drew DeVault <sir@cmpwn.com>
Date: Thu, 29 Mar 2018 18:08:23 -0400
Subject: [PATCH] Terminate swaybar when freeing bar config

---
 sway/config/bar.c | 22 +++++++++++-----------
 1 file 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 @@
 #include "list.h"
 #include "log.h"
 
+static void terminate_swaybar(pid_t pid) {
+	int ret = kill(pid, SIGTERM);
+	if (ret != 0) {
+		wlr_log_errno(L_ERROR, "Unable to terminate swaybar %d", pid);
+	} else {
+		int status;
+		waitpid(pid, &status, 0);
+	}
+}
+
 void free_bar_config(struct bar_config *bar) {
 	if (!bar) {
 		return;
@@ -31,7 +41,7 @@ void free_bar_config(struct bar_config *bar) {
 		free_flat_list(bar->outputs);
 	}
 	if (bar->pid != 0) {
-		// TODO terminate_swaybar(bar->pid);
+		terminate_swaybar(bar->pid);
 	}
 	free(bar->colors.background);
 	free(bar->colors.statusline);
@@ -191,16 +201,6 @@ void invoke_swaybar(struct bar_config *bar) {
 	close(filedes[1]);
 }
 
-static void terminate_swaybar(pid_t pid) {
-	int ret = kill(pid, SIGTERM);
-	if (ret != 0) {
-		wlr_log_errno(L_ERROR, "Unable to terminate swaybar %d", pid);
-	} else {
-		int status;
-		waitpid(pid, &status, 0);
-	}
-}
-
 static bool active_output(const char *name) {
 	swayc_t *cont = NULL;
 	for (int i = 0; i < root_container.children->length; ++i) {