aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-09-19 11:37:24 +0200
committeremersion <contact@emersion.fr>2018-09-20 18:37:51 +0200
commit82f1393cbb7383179eab2d10ff679a975d1f5c43 (patch)
tree97fd40cb652ac233fdbf03929da1977bc89d1bcb /sway
parentfa4308c5abecaeef870aced574e9d05e24e62392 (diff)
swaybar: handle hotplugging
Don't kill and respawn swaybars on hotplug.
Diffstat (limited to 'sway')
-rw-r--r--sway/config/bar.c26
-rw-r--r--sway/main.c1
-rw-r--r--sway/tree/output.c2
3 files changed, 7 insertions, 22 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:
return NULL;
}
-void invoke_swaybar(struct bar_config *bar) {
+static void invoke_swaybar(struct bar_config *bar) {
// Pipe to communicate errors
int filedes[2];
if (pipe(filedes) == -1) {
@@ -219,27 +219,13 @@ void invoke_swaybar(struct bar_config *bar) {
close(filedes[1]);
}
-void load_swaybars() {
+void load_swaybars(void) {
for (int i = 0; i < config->bars->length; ++i) {
struct bar_config *bar = config->bars->items[i];
- bool apply = false;
- if (bar->outputs) {
- for (int j = 0; j < bar->outputs->length; ++j) {
- char *o = bar->outputs->items[j];
- if (!strcmp(o, "*") || output_by_name(o)) {
- apply = true;
- break;
- }
- }
- } else {
- apply = true;
- }
- if (apply) {
- if (bar->pid != 0) {
- terminate_swaybar(bar->pid);
- }
- wlr_log(WLR_DEBUG, "Invoking swaybar for bar id '%s'", bar->id);
- invoke_swaybar(bar);
+ if (bar->pid != 0) {
+ terminate_swaybar(bar->pid);
}
+ wlr_log(WLR_DEBUG, "Invoking swaybar for bar id '%s'", bar->id);
+ invoke_swaybar(bar);
}
}
diff --git a/sway/main.c b/sway/main.c
index fb4f0d8c..3d7cd158 100644
--- a/sway/main.c
+++ b/sway/main.c
@@ -424,6 +424,7 @@ int main(int argc, char **argv) {
}
config->active = true;
+ load_swaybars();
// Execute commands until there are none left
wlr_log(WLR_DEBUG, "Running deferred commands");
while (config->cmd_queue->length) {
diff --git a/sway/tree/output.c b/sway/tree/output.c
index 1976ad51..06933dc4 100644
--- a/sway/tree/output.c
+++ b/sway/tree/output.c
@@ -109,8 +109,6 @@ void output_enable(struct sway_output *output, struct output_config *oc) {
wl_signal_emit(&root->events.new_node, &output->node);
- load_swaybars();
-
arrange_layers(output);
arrange_root();
}