diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-12-16 19:29:47 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-12-16 19:29:47 -0500 |
commit | 60c204a09b3b4ae999eca5e844858a0f34135723 (patch) | |
tree | eec810a1c29df53e220ccc3c7e0c298311fd8d76 | |
parent | Bring unmanaged windows to front on output arrange (diff) | |
download | sway-60c204a09b3b4ae999eca5e844858a0f34135723.tar.gz sway-60c204a09b3b4ae999eca5e844858a0f34135723.tar.zst sway-60c204a09b3b4ae999eca5e844858a0f34135723.zip |
Invoke swaybar when an output matches a bar config
-rw-r--r-- | sway/commands.c | 4 | ||||
-rw-r--r-- | sway/config.c | 46 |
2 files changed, 49 insertions, 1 deletions
diff --git a/sway/commands.c b/sway/commands.c index 4e9630ef..b40cdb6a 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -1785,6 +1785,10 @@ static struct cmd_results *bar_cmd_output(int argc, char **argv) { | |||
1785 | 1785 | ||
1786 | const char *output = argv[0]; | 1786 | const char *output = argv[0]; |
1787 | list_t *outputs = config->current_bar->outputs; | 1787 | list_t *outputs = config->current_bar->outputs; |
1788 | if (!outputs) { | ||
1789 | outputs = create_list(); | ||
1790 | config->current_bar->outputs = outputs; | ||
1791 | } | ||
1788 | 1792 | ||
1789 | int i; | 1793 | int i; |
1790 | int add_output = 1; | 1794 | int add_output = 1; |
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"); |