aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <RedSoxFan@users.noreply.github.com>2018-09-21 15:36:08 -0400
committerLibravatar GitHub <noreply@github.com>2018-09-21 15:36:08 -0400
commitd2a0a3cc0a29b3c3145bfedeb00ec68c1b8c5057 (patch)
tree56f257c17c0d97666c498d2eb35012838c82b451 /sway
parentMerge pull request #2672 from ianyfan/swaybar (diff)
parentMerge branch 'master' into swaybar-hotplug (diff)
downloadsway-d2a0a3cc0a29b3c3145bfedeb00ec68c1b8c5057.tar.gz
sway-d2a0a3cc0a29b3c3145bfedeb00ec68c1b8c5057.tar.zst
sway-d2a0a3cc0a29b3c3145bfedeb00ec68c1b8c5057.zip
Merge pull request #2666 from emersion/swaybar-hotplug
swaybar: handle hotplugging
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:
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}
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) {
424 } 424 }
425 425
426 config->active = true; 426 config->active = true;
427 load_swaybars();
427 // Execute commands until there are none left 428 // Execute commands until there are none left
428 wlr_log(WLR_DEBUG, "Running deferred commands"); 429 wlr_log(WLR_DEBUG, "Running deferred commands");
429 while (config->cmd_queue->length) { 430 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) {
109 109
110 wl_signal_emit(&root->events.new_node, &output->node); 110 wl_signal_emit(&root->events.new_node, &output->node);
111 111
112 load_swaybars();
113
114 arrange_layers(output); 112 arrange_layers(output);
115 arrange_root(); 113 arrange_root();
116} 114}