aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/i3bar.c
diff options
context:
space:
mode:
authorLibravatar Ian Fan <ianfan0@gmail.com>2018-09-17 14:21:14 +0100
committerLibravatar Ian Fan <ianfan0@gmail.com>2018-09-18 16:10:34 +0100
commit5912325d5ca63a552bb1f8e5de0b088e9bfa83e4 (patch)
tree230b7bcc12a33026d2796249738c508d6a0583fa /swaybar/i3bar.c
parentswaybar: rewrite i3bar protocol handling (diff)
downloadsway-5912325d5ca63a552bb1f8e5de0b088e9bfa83e4.tar.gz
sway-5912325d5ca63a552bb1f8e5de0b088e9bfa83e4.tar.zst
sway-5912325d5ca63a552bb1f8e5de0b088e9bfa83e4.zip
swaybar: add debugging statements for handling i3bar json
Diffstat (limited to 'swaybar/i3bar.c')
-rw-r--r--swaybar/i3bar.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/swaybar/i3bar.c b/swaybar/i3bar.c
index 78cb5bd4..88404703 100644
--- a/swaybar/i3bar.c
+++ b/swaybar/i3bar.c
@@ -176,6 +176,21 @@ bool i3bar_handle_readable(struct status_line *status) {
176 json_object_put(test_object); 176 json_object_put(test_object);
177 } 177 }
178 178
179 // in order to print the json for debugging purposes
180 // the last character is temporarily replaced with a null character
181 // (the last character is used in case the buffer is full)
182 char *last_char_pos =
183 &status->buffer[buffer_pos + status->tokener->char_offset - 1];
184 char last_char = *last_char_pos;
185 while (isspace(last_char)) {
186 last_char = *--last_char_pos;
187 }
188 *last_char_pos = '\0';
189 size_t offset = strspn(&status->buffer[buffer_pos], " \f\n\r\t\v");
190 wlr_log(WLR_DEBUG, "Received i3bar json: '%s%c'",
191 &status->buffer[buffer_pos + offset], last_char);
192 *last_char_pos = last_char;
193
179 buffer_pos += status->tokener->char_offset; 194 buffer_pos += status->tokener->char_offset;
180 status->expecting_comma = true; 195 status->expecting_comma = true;
181 196
@@ -221,6 +236,7 @@ bool i3bar_handle_readable(struct status_line *status) {
221 } 236 }
222 237
223 if (last_object) { 238 if (last_object) {
239 wlr_log(WLR_DEBUG, "Rendering last received json");
224 i3bar_parse_json(status, last_object); 240 i3bar_parse_json(status, last_object);
225 json_object_put(last_object); 241 json_object_put(last_object);
226 return true; 242 return true;