X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fipc.c;h=3733034dec5713ae6fabaef1988beadf83010088;hb=e114b3dba2485606cf5a3d044c0de8430c9f80b4;hp=ee418945f103467f9766b7e96e69f38f9a4b8cb2;hpb=3b7f4d428ed2176bc2ceaa8d20497b2aef8b2e89;p=i3%2Fi3 diff --git a/src/ipc.c b/src/ipc.c index ee418945..3733034d 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -119,16 +119,18 @@ IPC_HANDLER(command) { char *command = scalloc(message_size + 1); strncpy(command, (const char*)message, message_size); LOG("IPC: received: *%s*\n", command); - char *reply = parse_cmd((const char*)command); - char *save_reply = reply; + struct CommandResult *command_output = parse_command((const char*)command); free(command); + if (command_output->needs_tree_render) + tree_render(); + /* If no reply was provided, we just use the default success message */ - if (reply == NULL) - reply = "{\"success\":true}"; - ipc_send_message(fd, strlen(reply), I3_IPC_REPLY_TYPE_COMMAND, (const uint8_t*)reply); + ipc_send_message(fd, strlen(command_output->json_output), + I3_IPC_REPLY_TYPE_COMMAND, + (const uint8_t*)command_output->json_output); - FREE(save_reply); + free(command_output->json_output); } static void dump_rect(yajl_gen gen, const char *name, Rect r) {