From 3956833f4968dd8f2bf5cc9d38eda915ce28531b Mon Sep 17 00:00:00 2001 From: Hinara Turevel Date: Tue, 14 Dec 2021 23:59:29 +0100 Subject: [PATCH] swaybar: Fix multiple line on startup Fix regression on swaybar displaying multiple lines from the status_command introduced by 315b2bf. --- swaybar/status_line.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/swaybar/status_line.c b/swaybar/status_line.c index a97f3525..252f6037 100644 --- a/swaybar/status_line.c +++ b/swaybar/status_line.c @@ -115,6 +115,14 @@ bool status_handle_readable(struct status_line *status) { sway_log(SWAY_DEBUG, "Using text protocol."); status->protocol = PROTOCOL_TEXT; status->text = status->buffer; + newline = strrchr(status->buffer, '\n'); + if (newline != NULL && newline[1] == '\0') { + newline[0] = '\0'; + newline = strrchr(status->buffer, '\n'); + } + if (newline != NULL) { + memmove(status->buffer, newline + 1, strlen(newline + 1) + 1); + } // intentional fall-through case PROTOCOL_TEXT: errno = 0;