diff options
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | sway/ipc.c | 13 |
2 files changed, 17 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index bbf61299..e30b52e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -22,12 +22,15 @@ find_package(XKBCommon REQUIRED) | |||
22 | find_package(WLC REQUIRED) | 22 | find_package(WLC REQUIRED) |
23 | find_package(A2X REQUIRED) | 23 | find_package(A2X REQUIRED) |
24 | find_package(PCRE REQUIRED) | 24 | find_package(PCRE REQUIRED) |
25 | find_package(PkgConfig REQUIRED) | ||
26 | pkg_check_modules(JSON REQUIRED json-c) | ||
25 | 27 | ||
26 | FILE(GLOB sources ${PROJECT_SOURCE_DIR}/sway/*.c) | 28 | FILE(GLOB sources ${PROJECT_SOURCE_DIR}/sway/*.c) |
27 | 29 | ||
28 | include_directories( | 30 | include_directories( |
29 | ${WLC_INCLUDE_DIRS} | 31 | ${WLC_INCLUDE_DIRS} |
30 | ${PCRE_INCLUDE_DIRS} | 32 | ${PCRE_INCLUDE_DIRS} |
33 | ${JSON_INCLUDE_DIRS} | ||
31 | include/ | 34 | include/ |
32 | ) | 35 | ) |
33 | 36 | ||
@@ -39,6 +42,7 @@ target_link_libraries(sway | |||
39 | ${WLC_LIBRARIES} | 42 | ${WLC_LIBRARIES} |
40 | ${XKBCOMMON_LIBRARIES} | 43 | ${XKBCOMMON_LIBRARIES} |
41 | ${PCRE_LIBRARIES} | 44 | ${PCRE_LIBRARIES} |
45 | ${JSON_LIBRARIES} | ||
42 | ) | 46 | ) |
43 | 47 | ||
44 | INSTALL( | 48 | INSTALL( |
@@ -12,6 +12,7 @@ | |||
12 | #include <sys/ioctl.h> | 12 | #include <sys/ioctl.h> |
13 | #include <fcntl.h> | 13 | #include <fcntl.h> |
14 | #include <ctype.h> | 14 | #include <ctype.h> |
15 | #include <json-c/json.h> | ||
15 | #include "ipc.h" | 16 | #include "ipc.h" |
16 | #include "log.h" | 17 | #include "log.h" |
17 | #include "config.h" | 18 | #include "config.h" |
@@ -226,6 +227,18 @@ void ipc_client_handle_command(struct ipc_client *client) { | |||
226 | free(json); | 227 | free(json); |
227 | break; | 228 | break; |
228 | } | 229 | } |
230 | case IPC_GET_VERSION: | ||
231 | { | ||
232 | json_object *json = json_object_new_object(); | ||
233 | json_object_object_add(json, "human_readable", json_object_new_string(SWAY_GIT_VERSION)); | ||
234 | json_object_object_add(json, "major", json_object_new_int(0)); | ||
235 | json_object_object_add(json, "minor", json_object_new_int(0)); | ||
236 | json_object_object_add(json, "patch", json_object_new_int(1)); | ||
237 | const char *json_string = json_object_to_json_string(json); | ||
238 | ipc_send_reply(client, json_string, (uint32_t) strlen(json_string)); | ||
239 | json_object_put(json); // free | ||
240 | break; | ||
241 | } | ||
229 | default: | 242 | default: |
230 | sway_log(L_INFO, "Unknown IPC command type %i", client->current_command); | 243 | sway_log(L_INFO, "Unknown IPC command type %i", client->current_command); |
231 | ipc_client_disconnect(client); | 244 | ipc_client_disconnect(client); |