summaryrefslogtreecommitdiffstats
path: root/sway/config
diff options
context:
space:
mode:
authorLibravatar emersion <contact@emersion.fr>2018-09-19 11:37:24 +0200
committerLibravatar emersion <contact@emersion.fr>2018-09-20 18:37:51 +0200
commit82f1393cbb7383179eab2d10ff679a975d1f5c43 (patch)
tree97fd40cb652ac233fdbf03929da1977bc89d1bcb /sway/config
parentMerge pull request #2671 from emersion/output-execute-no-focus (diff)
downloadsway-82f1393cbb7383179eab2d10ff679a975d1f5c43.tar.gz
sway-82f1393cbb7383179eab2d10ff679a975d1f5c43.tar.zst
sway-82f1393cbb7383179eab2d10ff679a975d1f5c43.zip
swaybar: handle hotplugging
Don't kill and respawn swaybars on hotplug.
Diffstat (limited to 'sway/config')
-rw-r--r--sway/config/bar.c26
1 files changed, 6 insertions, 20 deletions
diff --git a/sway/config/bar.c b/sway/config/bar.c
index f83b37d1..48a632fb 100644
--- a/sway/config/bar.c
+++ b/sway/config/bar.c
@@ -165,7 +165,7 @@ cleanup:
165 return NULL; 165 return NULL;
166} 166}
167 167
168void invoke_swaybar(struct bar_config *bar) { 168static void invoke_swaybar(struct bar_config *bar) {
169 // Pipe to communicate errors 169 // Pipe to communicate errors
170 int filedes[2]; 170 int filedes[2];
171 if (pipe(filedes) == -1) { 171 if (pipe(filedes) == -1) {
@@ -219,27 +219,13 @@ void invoke_swaybar(struct bar_config *bar) {
219 close(filedes[1]); 219 close(filedes[1]);
220} 220}
221 221
222void load_swaybars() { 222void load_swaybars(void) {
223 for (int i = 0; i < config->bars->length; ++i) { 223 for (int i = 0; i < config->bars->length; ++i) {
224 struct bar_config *bar = config->bars->items[i]; 224 struct bar_config *bar = config->bars->items[i];
225 bool apply = false; 225 if (bar->pid != 0) {
226 if (bar->outputs) { 226 terminate_swaybar(bar->pid);
227 for (int j = 0; j < bar->outputs->length; ++j) {
228 char *o = bar->outputs->items[j];
229 if (!strcmp(o, "*") || output_by_name(o)) {
230 apply = true;
231 break;
232 }
233 }
234 } else {
235 apply = true;
236 }
237 if (apply) {
238 if (bar->pid != 0) {
239 terminate_swaybar(bar->pid);
240 }
241 wlr_log(WLR_DEBUG, "Invoking swaybar for bar id '%s'", bar->id);
242 invoke_swaybar(bar);
243 } 227 }
228 wlr_log(WLR_DEBUG, "Invoking swaybar for bar id '%s'", bar->id);
229 invoke_swaybar(bar);
244 } 230 }
245} 231}