summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt4
-rw-r--r--sway/ipc.c13
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)
22find_package(WLC REQUIRED) 22find_package(WLC REQUIRED)
23find_package(A2X REQUIRED) 23find_package(A2X REQUIRED)
24find_package(PCRE REQUIRED) 24find_package(PCRE REQUIRED)
25find_package(PkgConfig REQUIRED)
26pkg_check_modules(JSON REQUIRED json-c)
25 27
26FILE(GLOB sources ${PROJECT_SOURCE_DIR}/sway/*.c) 28FILE(GLOB sources ${PROJECT_SOURCE_DIR}/sway/*.c)
27 29
28include_directories( 30include_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
44INSTALL( 48INSTALL(
diff --git a/sway/ipc.c b/sway/ipc.c
index 0b36d758..c5b72db7 100644
--- a/sway/ipc.c
+++ b/sway/ipc.c
@@ -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);