From a83bca6db5348033b21ebb4ed7bc189d39e2b0c4 Mon Sep 17 00:00:00 2001 From: Calvin Lee Date: Sun, 4 Feb 2018 10:37:46 -0700 Subject: Handle swaybar status line errors The event loop API was redesigned to avoid race conditions as well. Fixes #1583 --- swaybar/status_line.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'swaybar/status_line.c') 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) { return dirty; } +void handle_status_hup(struct status_line *line) { + // This is somewhat hacky, but free all previous status line state and + // then create a status block that displays an error string. This is so + // we can have pretty error colors. + sway_log(L_ERROR, "Replacing statusline with error string, as the status command has failed"); + if (line->block_line) { + list_foreach(line->block_line, free_status_block); + list_free(line->block_line); + } + line->block_line = create_list(); + struct status_block *new = calloc(1, sizeof(struct status_block)); + new->full_text = strdup("ERROR: swaybar cannot access the statusline"); + new->color = 0xff0000ff; + new->min_width = 0; + new->align = strdup("left"); + new->markup = false; + new->separator = true; + new->separator_block_width = 9; + new->background = 0x0; + new->border = 0x0; + new->border_top = 1; + new->border_bottom = 1; + new->border_left = 1; + new->border_right = 1; + list_add(line->block_line, new); + + line->protocol = I3BAR; +} + struct status_line *init_status_line() { struct status_line *line = malloc(sizeof(struct status_line)); line->block_line = create_list(); -- cgit v1.2.3-70-g09d2