diff options
Diffstat (limited to 'swaybar/i3bar.c')
-rw-r--r-- | swaybar/i3bar.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/swaybar/i3bar.c b/swaybar/i3bar.c index ed134a01..923ad755 100644 --- a/swaybar/i3bar.c +++ b/swaybar/i3bar.c | |||
@@ -113,8 +113,9 @@ bool i3bar_handle_readable(struct status_line *status) { | |||
113 | char *cur = &state->buffer[state->buffer_index]; | 113 | char *cur = &state->buffer[state->buffer_index]; |
114 | ssize_t n = read(status->read_fd, cur, | 114 | ssize_t n = read(status->read_fd, cur, |
115 | state->buffer_size - state->buffer_index); | 115 | state->buffer_size - state->buffer_index); |
116 | if (n == 0) { | 116 | if (n == -1) { |
117 | return 0; | 117 | status_error(status, "[failed to read from status command]"); |
118 | return false; | ||
118 | } | 119 | } |
119 | 120 | ||
120 | if (n == (ssize_t)(state->buffer_size - state->buffer_index)) { | 121 | if (n == (ssize_t)(state->buffer_size - state->buffer_index)) { |
@@ -123,11 +124,14 @@ bool i3bar_handle_readable(struct status_line *status) { | |||
123 | if (!new_buffer) { | 124 | if (!new_buffer) { |
124 | free(state->buffer); | 125 | free(state->buffer); |
125 | status_error(status, "[failed to allocate buffer]"); | 126 | status_error(status, "[failed to allocate buffer]"); |
126 | return -1; | 127 | return true; |
127 | } | 128 | } |
129 | state->current_node += new_buffer - state->buffer; | ||
130 | cur += new_buffer - state->buffer; | ||
128 | state->buffer = new_buffer; | 131 | state->buffer = new_buffer; |
129 | } | 132 | } |
130 | 133 | ||
134 | cur[n] = '\0'; | ||
131 | bool redraw = false; | 135 | bool redraw = false; |
132 | while (*cur) { | 136 | while (*cur) { |
133 | if (state->nodes[state->depth] == JSON_NODE_STRING) { | 137 | if (state->nodes[state->depth] == JSON_NODE_STRING) { |