diff options
author | 2018-02-04 10:37:46 -0700 | |
---|---|---|
committer | 2018-02-04 12:31:07 -0700 | |
commit | a83bca6db5348033b21ebb4ed7bc189d39e2b0c4 (patch) | |
tree | ab10cd02219ad353a97794139e92e8801ce5871f /swaybar/status_line.c | |
parent | Merge pull request #1579 from tmccombs/patch-1 (diff) | |
download | sway-a83bca6db5348033b21ebb4ed7bc189d39e2b0c4.tar.gz sway-a83bca6db5348033b21ebb4ed7bc189d39e2b0c4.tar.zst sway-a83bca6db5348033b21ebb4ed7bc189d39e2b0c4.zip |
Handle swaybar status line errors
The event loop API was redesigned to avoid race conditions as well.
Fixes #1583
Diffstat (limited to 'swaybar/status_line.c')
-rw-r--r-- | swaybar/status_line.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/swaybar/status_line.c b/swaybar/status_line.c index e3cc0bf4..bbb798f1 100644 --- a/swaybar/status_line.c +++ b/swaybar/status_line.c | |||
@@ -511,6 +511,35 @@ bool handle_status_line(struct bar *bar) { | |||
511 | return dirty; | 511 | return dirty; |
512 | } | 512 | } |
513 | 513 | ||
514 | void handle_status_hup(struct status_line *line) { | ||
515 | // This is somewhat hacky, but free all previous status line state and | ||
516 | // then create a status block that displays an error string. This is so | ||
517 | // we can have pretty error colors. | ||
518 | sway_log(L_ERROR, "Replacing statusline with error string, as the status command has failed"); | ||
519 | if (line->block_line) { | ||
520 | list_foreach(line->block_line, free_status_block); | ||
521 | list_free(line->block_line); | ||
522 | } | ||
523 | line->block_line = create_list(); | ||
524 | struct status_block *new = calloc(1, sizeof(struct status_block)); | ||
525 | new->full_text = strdup("ERROR: swaybar cannot access the statusline"); | ||
526 | new->color = 0xff0000ff; | ||
527 | new->min_width = 0; | ||
528 | new->align = strdup("left"); | ||
529 | new->markup = false; | ||
530 | new->separator = true; | ||
531 | new->separator_block_width = 9; | ||
532 | new->background = 0x0; | ||
533 | new->border = 0x0; | ||
534 | new->border_top = 1; | ||
535 | new->border_bottom = 1; | ||
536 | new->border_left = 1; | ||
537 | new->border_right = 1; | ||
538 | list_add(line->block_line, new); | ||
539 | |||
540 | line->protocol = I3BAR; | ||
541 | } | ||
542 | |||
514 | struct status_line *init_status_line() { | 543 | struct status_line *init_status_line() { |
515 | struct status_line *line = malloc(sizeof(struct status_line)); | 544 | struct status_line *line = malloc(sizeof(struct status_line)); |
516 | line->block_line = create_list(); | 545 | line->block_line = create_list(); |