diff options
Diffstat (limited to 'sway/config.c')
-rw-r--r-- | sway/config.c | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/sway/config.c b/sway/config.c index 7222b7a2..9b441223 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -424,6 +424,50 @@ void apply_output_config(struct output_config *oc, swayc_t *output) { | |||
424 | execvp(cmd[0], cmd); | 424 | execvp(cmd[0], cmd); |
425 | } | 425 | } |
426 | } | 426 | } |
427 | |||
428 | // Check for a bar | ||
429 | struct bar_config *bar = NULL; | ||
430 | int i; | ||
431 | for (i = 0; i < config->bars->length; ++i) { | ||
432 | bar = config->bars->items[i]; | ||
433 | bool apply = false; | ||
434 | if (bar->outputs) { | ||
435 | int j; | ||
436 | for (j = 0; j < bar->outputs->length; ++j) { | ||
437 | char *o = bar->outputs->items[j]; | ||
438 | if (strcmp(o, "*") || strcasecmp(o, output->name)) { | ||
439 | apply = true; | ||
440 | break; | ||
441 | } | ||
442 | } | ||
443 | } else { | ||
444 | apply = true; | ||
445 | } | ||
446 | if (apply) { | ||
447 | break; | ||
448 | } else { | ||
449 | bar = NULL; | ||
450 | } | ||
451 | } | ||
452 | if (bar) { | ||
453 | sway_log(L_DEBUG, "Invoking swaybar for output %s and bar %s", output->name, bar->id); | ||
454 | |||
455 | size_t bufsize = 4; | ||
456 | char output_id[bufsize]; | ||
457 | snprintf(output_id, bufsize, "%d", i); | ||
458 | output_id[bufsize-1] = 0; | ||
459 | |||
460 | char *const cmd[] = { | ||
461 | "./bin/swaybar", | ||
462 | "-b", | ||
463 | bar->id, | ||
464 | output_id, | ||
465 | NULL, | ||
466 | }; | ||
467 | if (fork() == 0) { | ||
468 | execvp(cmd[0], cmd); | ||
469 | } | ||
470 | } | ||
427 | } | 471 | } |
428 | 472 | ||
429 | char *do_var_replacement(char *str) { | 473 | char *do_var_replacement(char *str) { |
@@ -561,7 +605,7 @@ struct bar_config *default_bar_config(void) { | |||
561 | bar->mode = strdup("dock"); | 605 | bar->mode = strdup("dock"); |
562 | bar->hidden_state = strdup("hide"); | 606 | bar->hidden_state = strdup("hide"); |
563 | bar->modifier = 0; | 607 | bar->modifier = 0; |
564 | bar->outputs = create_list(); | 608 | bar->outputs = NULL; |
565 | bar->position = DESKTOP_SHELL_PANEL_POSITION_BOTTOM; | 609 | bar->position = DESKTOP_SHELL_PANEL_POSITION_BOTTOM; |
566 | bar->bindings = create_list(); | 610 | bar->bindings = create_list(); |
567 | bar->status_command = strdup("while :; do date +'%Y-%m-%d %l:%M:%S %p' && sleep 1; done"); | 611 | bar->status_command = strdup("while :; do date +'%Y-%m-%d %l:%M:%S %p' && sleep 1; done"); |