swaybar: Fix multiple line on startup

Fix regression on swaybar displaying multiple lines from the
status_command introduced by 315b2bf.
This commit is contained in:
Hinara Turevel 2021-12-14 23:59:29 +01:00
parent f2b6d1ec29
commit 3956833f49

View file

@ -115,6 +115,14 @@ bool status_handle_readable(struct status_line *status) {
sway_log(SWAY_DEBUG, "Using text protocol."); sway_log(SWAY_DEBUG, "Using text protocol.");
status->protocol = PROTOCOL_TEXT; status->protocol = PROTOCOL_TEXT;
status->text = status->buffer; 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 // intentional fall-through
case PROTOCOL_TEXT: case PROTOCOL_TEXT:
errno = 0; errno = 0;