aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/status_line.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaybar/status_line.c')
-rw-r--r--swaybar/status_line.c29
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
514void 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
514struct status_line *init_status_line() { 543struct 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();