swaybar: only display the last status line

This commit is contained in:
Jason Nader 2020-03-14 12:41:54 +09:00
parent 55016729a5
commit b99308b026
No known key found for this signature in database
GPG key ID: EE220FCAA09AF23D

View file

@ -113,6 +113,11 @@ 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;
char *last_newline = strrchr(status->buffer, '\n');
if (last_newline != NULL) {
status->buffer_index = strlen(last_newline + 1);
memmove(status->buffer, last_newline + 1, status->buffer_index + 1);
}
status->text = status->buffer; status->text = status->buffer;
// intentional fall-through // intentional fall-through
case PROTOCOL_TEXT: case PROTOCOL_TEXT: