aboutsummaryrefslogtreecommitdiffstats
path: root/sway/ipc.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/ipc.c')
-rw-r--r--sway/ipc.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/sway/ipc.c b/sway/ipc.c
index d278c0a0..44891005 100644
--- a/sway/ipc.c
+++ b/sway/ipc.c
@@ -225,14 +225,30 @@ void ipc_client_handle_command(struct ipc_client *client) {
225 } 225 }
226 case IPC_GET_VERSION: 226 case IPC_GET_VERSION:
227 { 227 {
228#if defined SWAY_GIT_VERSION && defined SWAY_GIT_BRANCH && defined SWAY_VERSION_DATE
229 char *full_version = calloc(strlen(SWAY_GIT_VERSION) + strlen(SWAY_GIT_BRANCH) + strlen(SWAY_VERSION_DATE) + 20, 1);
230 strcat(full_version, SWAY_GIT_VERSION);
231 strcat(full_version, " (");
232 strcat(full_version, SWAY_VERSION_DATE);
233 strcat(full_version, ", branch \"");
234 strcat(full_version, SWAY_GIT_BRANCH);
235 strcat(full_version, "\")");
228 json_object *json = json_object_new_object(); 236 json_object *json = json_object_new_object();
229 json_object_object_add(json, "human_readable", json_object_new_string(SWAY_GIT_VERSION)); 237 json_object_object_add(json, "human_readable", json_object_new_string(full_version));
238 // Todo once we actually release a version
230 json_object_object_add(json, "major", json_object_new_int(0)); 239 json_object_object_add(json, "major", json_object_new_int(0));
231 json_object_object_add(json, "minor", json_object_new_int(0)); 240 json_object_object_add(json, "minor", json_object_new_int(0));
232 json_object_object_add(json, "patch", json_object_new_int(1)); 241 json_object_object_add(json, "patch", json_object_new_int(1));
242#else
243 json_object_object_add(json, "human_readable", json_object_new_string("version not found"));
244 json_object_object_add(json, "major", json_object_new_int(0));
245 json_object_object_add(json, "minor", json_object_new_int(0));
246 json_object_object_add(json, "patch", json_object_new_int(0));
247#endif
233 const char *json_string = json_object_to_json_string(json); 248 const char *json_string = json_object_to_json_string(json);
234 ipc_send_reply(client, json_string, (uint32_t) strlen(json_string)); 249 ipc_send_reply(client, json_string, (uint32_t) strlen(json_string));
235 json_object_put(json); // free 250 json_object_put(json); // free
251 free(full_version);
236 break; 252 break;
237 } 253 }
238 default: 254 default: