mirror of
https://github.com/swaywm/sway.git
synced 2025-11-19 06:59:52 -05:00
swaybar: handle hotplugging
Don't kill and respawn swaybars on hotplug.
This commit is contained in:
parent
fa4308c5ab
commit
82f1393cbb
6 changed files with 81 additions and 66 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue