2 #define I3__FILE__ "ipc.c"
4 * vim:ts=4:sw=4:expandtab
6 * i3 - an improved dynamic tiling window manager
7 * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
9 * ipc.c: UNIX domain socket IPC (initialization, client handling, protocol).
13 #include "yajl_utils.h"
15 #include <sys/socket.h>
20 #include <yajl/yajl_gen.h>
21 #include <yajl/yajl_parse.h>
23 char *current_socketpath = NULL;
25 TAILQ_HEAD(ipc_client_head, ipc_client) all_clients = TAILQ_HEAD_INITIALIZER(all_clients);
28 * Puts the given socket file descriptor into non-blocking mode or dies if
29 * setting O_NONBLOCK failed. Non-blocking sockets are a good idea for our
30 * IPC model because we should by no means block the window manager.
33 static void set_nonblock(int sockfd) {
34 int flags = fcntl(sockfd, F_GETFL, 0);
36 if (fcntl(sockfd, F_SETFL, flags) < 0)
37 err(-1, "Could not set O_NONBLOCK");
41 * Sends the specified event to all IPC clients which are currently connected
42 * and subscribed to this kind of event.
45 void ipc_send_event(const char *event, uint32_t message_type, const char *payload) {
47 TAILQ_FOREACH(current, &all_clients, clients) {
48 /* see if this client is interested in this event */
49 bool interested = false;
50 for (int i = 0; i < current->num_events; i++) {
51 if (strcasecmp(current->events[i], event) != 0)
59 ipc_send_message(current->fd, strlen(payload), message_type, (const uint8_t *)payload);
64 * Calls shutdown() on each socket and closes it. This function to be called
65 * when exiting or restarting only!
68 void ipc_shutdown(void) {
70 while (!TAILQ_EMPTY(&all_clients)) {
71 current = TAILQ_FIRST(&all_clients);
72 shutdown(current->fd, SHUT_RDWR);
74 TAILQ_REMOVE(&all_clients, current, clients);
80 * Executes the command and returns whether it could be successfully parsed
81 * or not (at the moment, always returns true).
84 IPC_HANDLER(command) {
85 /* To get a properly terminated buffer, we copy
86 * message_size bytes out of the buffer */
87 char *command = scalloc(message_size + 1, 1);
88 strncpy(command, (const char *)message, message_size);
89 LOG("IPC: received: *%s*\n", command);
90 yajl_gen gen = yajl_gen_alloc(NULL);
92 CommandResult *result = parse_command((const char *)command, gen);
95 if (result->needs_tree_render)
98 command_result_free(result);
100 const unsigned char *reply;
102 yajl_gen_get_buf(gen, &reply, &length);
104 ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_COMMAND,
105 (const uint8_t *)reply);
110 static void dump_rect(yajl_gen gen, const char *name, Rect r) {
120 y(integer, r.height);
124 static void dump_event_state_mask(yajl_gen gen, Binding *bind) {
126 for (int i = 0; i < 20; i++) {
127 if (bind->event_state_mask & (1 << i)) {
129 case XCB_KEY_BUT_MASK_SHIFT:
132 case XCB_KEY_BUT_MASK_LOCK:
135 case XCB_KEY_BUT_MASK_CONTROL:
138 case XCB_KEY_BUT_MASK_MOD_1:
141 case XCB_KEY_BUT_MASK_MOD_2:
144 case XCB_KEY_BUT_MASK_MOD_3:
147 case XCB_KEY_BUT_MASK_MOD_4:
150 case XCB_KEY_BUT_MASK_MOD_5:
153 case XCB_KEY_BUT_MASK_BUTTON_1:
156 case XCB_KEY_BUT_MASK_BUTTON_2:
159 case XCB_KEY_BUT_MASK_BUTTON_3:
162 case XCB_KEY_BUT_MASK_BUTTON_4:
165 case XCB_KEY_BUT_MASK_BUTTON_5:
168 case (I3_XKB_GROUP_MASK_1 << 16):
171 case (I3_XKB_GROUP_MASK_2 << 16):
174 case (I3_XKB_GROUP_MASK_3 << 16):
177 case (I3_XKB_GROUP_MASK_4 << 16):
186 static void dump_binding(yajl_gen gen, Binding *bind) {
189 y(integer, bind->keycode);
192 ystr((const char *)(bind->input_type == B_KEYBOARD ? "keyboard" : "mouse"));
195 if (bind->symbol == NULL)
203 // This key is only provided for compatibility, new programs should use
204 // event_state_mask instead.
206 dump_event_state_mask(gen, bind);
208 ystr("event_state_mask");
209 dump_event_state_mask(gen, bind);
214 void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
217 y(integer, (long int)con);
230 case CT_FLOATING_CON:
231 ystr("floating_con");
240 DLOG("About to dump unknown container type=%d. This is a bug.\n", con->type);
245 /* provided for backwards compatibility only. */
247 if (!con_is_split(con))
250 if (con_orientation(con) == HORIZ)
256 ystr("scratchpad_state");
257 switch (con->scratchpad_state) {
258 case SCRATCHPAD_NONE:
261 case SCRATCHPAD_FRESH:
264 case SCRATCHPAD_CHANGED:
270 if (con->percent == 0.0)
273 y(double, con->percent);
276 y(bool, con->urgent);
278 if (!TAILQ_EMPTY(&(con->marks_head))) {
283 TAILQ_FOREACH(mark, &(con->marks_head), marks) {
291 y(bool, (con == focused));
294 switch (con->layout) {
296 DLOG("About to dump layout=default, this is a bug in the code.\n");
319 ystr("workspace_layout");
320 switch (con->workspace_layout) {
331 DLOG("About to dump workspace_layout=%d (none of default/stacked/tabbed), this is a bug.\n", con->workspace_layout);
336 ystr("last_split_layout");
337 switch (con->layout) {
347 switch (con->border_style) {
359 ystr("current_border_width");
360 y(integer, con->current_border_width);
362 dump_rect(gen, "rect", con->rect);
363 dump_rect(gen, "deco_rect", con->deco_rect);
364 dump_rect(gen, "window_rect", con->window_rect);
365 dump_rect(gen, "geometry", con->geometry);
368 if (con->window && con->window->name)
369 ystr(i3string_as_utf8(con->window->name));
370 else if (con->name != NULL)
375 if (con->type == CT_WORKSPACE) {
377 y(integer, con->num);
382 y(integer, con->window->id);
386 if (con->window && !inplace_restart) {
387 /* Window properties are useless to preserve when restarting because
388 * they will be queried again anyway. However, for i3-save-tree(1),
389 * they are very useful and save i3-save-tree dealing with X11. */
390 ystr("window_properties");
393 #define DUMP_PROPERTY(key, prop_name) \
395 if (con->window->prop_name != NULL) { \
397 ystr(con->window->prop_name); \
401 DUMP_PROPERTY("class", class_class);
402 DUMP_PROPERTY("instance", class_instance);
403 DUMP_PROPERTY("window_role", role);
405 if (con->window->name != NULL) {
407 ystr(i3string_as_utf8(con->window->name));
410 ystr("transient_for");
411 if (con->window->transient_for == XCB_NONE)
414 y(integer, con->window->transient_for);
422 if (con->type != CT_DOCKAREA || !inplace_restart) {
423 TAILQ_FOREACH(node, &(con->nodes_head), nodes) {
424 dump_node(gen, node, inplace_restart);
429 ystr("floating_nodes");
431 TAILQ_FOREACH(node, &(con->floating_head), floating_windows) {
432 dump_node(gen, node, inplace_restart);
438 TAILQ_FOREACH(node, &(con->focus_head), focused) {
439 y(integer, (long int)node);
443 ystr("fullscreen_mode");
444 y(integer, con->fullscreen_mode);
447 y(bool, con->sticky);
450 switch (con->floating) {
451 case FLOATING_AUTO_OFF:
454 case FLOATING_AUTO_ON:
457 case FLOATING_USER_OFF:
460 case FLOATING_USER_ON:
468 TAILQ_FOREACH(match, &(con->swallow_head), matches) {
469 /* We will generate a new restart_mode match specification after this
470 * loop, so skip this one. */
471 if (match->restart_mode)
474 if (match->dock != -1) {
476 y(integer, match->dock);
477 ystr("insert_where");
478 y(integer, match->insert_where);
481 #define DUMP_REGEX(re_name) \
483 if (match->re_name != NULL) { \
485 ystr(match->re_name->pattern); \
490 DUMP_REGEX(instance);
491 DUMP_REGEX(window_role);
498 if (inplace_restart) {
499 if (con->window != NULL) {
502 y(integer, con->window->id);
503 ystr("restart_mode");
510 if (inplace_restart && con->window != NULL) {
512 y(integer, con->depth);
518 static void dump_bar_bindings(yajl_gen gen, Barconfig *config) {
519 if (TAILQ_EMPTY(&(config->bar_bindings)))
525 struct Barbinding *current;
526 TAILQ_FOREACH(current, &(config->bar_bindings), bindings) {
530 y(integer, current->input_code);
532 ystr(current->command);
540 static void dump_bar_config(yajl_gen gen, Barconfig *config) {
546 if (config->num_outputs > 0) {
549 for (int c = 0; c < config->num_outputs; c++)
550 ystr(config->outputs[c]);
554 if (!TAILQ_EMPTY(&(config->tray_outputs))) {
555 ystr("tray_outputs");
558 struct tray_output_t *tray_output;
559 TAILQ_FOREACH(tray_output, &(config->tray_outputs), tray_outputs) {
560 ystr(tray_output->output);
566 #define YSTR_IF_SET(name) \
568 if (config->name) { \
570 ystr(config->name); \
574 ystr("tray_padding");
575 y(integer, config->tray_padding);
577 YSTR_IF_SET(socket_path);
580 switch (config->mode) {
593 ystr("hidden_state");
594 switch (config->hidden_state) {
605 switch (config->modifier) {
634 dump_bar_bindings(gen, config);
637 if (config->position == P_BOTTOM)
642 YSTR_IF_SET(status_command);
645 if (config->separator_symbol) {
646 ystr("separator_symbol");
647 ystr(config->separator_symbol);
650 ystr("workspace_buttons");
651 y(bool, !config->hide_workspace_buttons);
653 ystr("strip_workspace_numbers");
654 y(bool, config->strip_workspace_numbers);
656 ystr("binding_mode_indicator");
657 y(bool, !config->hide_binding_mode_indicator);
660 y(bool, config->verbose);
663 #define YSTR_IF_SET(name) \
665 if (config->colors.name) { \
667 ystr(config->colors.name); \
673 YSTR_IF_SET(background);
674 YSTR_IF_SET(statusline);
675 YSTR_IF_SET(separator);
676 YSTR_IF_SET(focused_background);
677 YSTR_IF_SET(focused_statusline);
678 YSTR_IF_SET(focused_separator);
679 YSTR_IF_SET(focused_workspace_border);
680 YSTR_IF_SET(focused_workspace_bg);
681 YSTR_IF_SET(focused_workspace_text);
682 YSTR_IF_SET(active_workspace_border);
683 YSTR_IF_SET(active_workspace_bg);
684 YSTR_IF_SET(active_workspace_text);
685 YSTR_IF_SET(inactive_workspace_border);
686 YSTR_IF_SET(inactive_workspace_bg);
687 YSTR_IF_SET(inactive_workspace_text);
688 YSTR_IF_SET(urgent_workspace_border);
689 YSTR_IF_SET(urgent_workspace_bg);
690 YSTR_IF_SET(urgent_workspace_text);
691 YSTR_IF_SET(binding_mode_border);
692 YSTR_IF_SET(binding_mode_bg);
693 YSTR_IF_SET(binding_mode_text);
701 setlocale(LC_NUMERIC, "C");
702 yajl_gen gen = ygenalloc();
703 dump_node(gen, croot, false);
704 setlocale(LC_NUMERIC, "");
706 const unsigned char *payload;
708 y(get_buf, &payload, &length);
710 ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_TREE, payload);
715 * Formats the reply message for a GET_WORKSPACES request and sends it to the
719 IPC_HANDLER(get_workspaces) {
720 yajl_gen gen = ygenalloc();
723 Con *focused_ws = con_get_workspace(focused);
726 TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
727 if (con_is_internal(output))
730 TAILQ_FOREACH(ws, &(output_get_content(output)->nodes_head), nodes) {
731 assert(ws->type == CT_WORKSPACE);
741 y(bool, workspace_is_visible(ws));
744 y(bool, ws == focused_ws);
749 y(integer, ws->rect.x);
751 y(integer, ws->rect.y);
753 y(integer, ws->rect.width);
755 y(integer, ws->rect.height);
770 const unsigned char *payload;
772 y(get_buf, &payload, &length);
774 ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_WORKSPACES, payload);
779 * Formats the reply message for a GET_OUTPUTS request and sends it to the
783 IPC_HANDLER(get_outputs) {
784 yajl_gen gen = ygenalloc();
788 TAILQ_FOREACH(output, &outputs, outputs) {
795 y(bool, output->active);
798 y(bool, output->primary);
803 y(integer, output->rect.x);
805 y(integer, output->rect.y);
807 y(integer, output->rect.width);
809 y(integer, output->rect.height);
812 ystr("current_workspace");
814 if (output->con && (ws = con_get_fullscreen_con(output->con, CF_OUTPUT)))
824 const unsigned char *payload;
826 y(get_buf, &payload, &length);
828 ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_OUTPUTS, payload);
833 * Formats the reply message for a GET_MARKS request and sends it to the
837 IPC_HANDLER(get_marks) {
838 yajl_gen gen = ygenalloc();
842 TAILQ_FOREACH(con, &all_cons, all_cons) {
844 TAILQ_FOREACH(mark, &(con->marks_head), marks) {
851 const unsigned char *payload;
853 y(get_buf, &payload, &length);
855 ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_MARKS, payload);
860 * Returns the version of i3
863 IPC_HANDLER(get_version) {
864 yajl_gen gen = ygenalloc();
868 y(integer, MAJOR_VERSION);
871 y(integer, MINOR_VERSION);
874 y(integer, PATCH_VERSION);
876 ystr("human_readable");
879 ystr("loaded_config_file_name");
880 ystr(current_configpath);
884 const unsigned char *payload;
886 y(get_buf, &payload, &length);
888 ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_VERSION, payload);
893 * Formats the reply message for a GET_BAR_CONFIG request and sends it to the
897 IPC_HANDLER(get_bar_config) {
898 yajl_gen gen = ygenalloc();
900 /* If no ID was passed, we return a JSON array with all IDs */
901 if (message_size == 0) {
904 TAILQ_FOREACH(current, &barconfigs, configs) {
909 const unsigned char *payload;
911 y(get_buf, &payload, &length);
913 ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_BAR_CONFIG, payload);
918 /* To get a properly terminated buffer, we copy
919 * message_size bytes out of the buffer */
921 sasprintf(&bar_id, "%.*s", message_size, message);
922 LOG("IPC: looking for config for bar ID \"%s\"\n", bar_id);
923 Barconfig *current, *config = NULL;
924 TAILQ_FOREACH(current, &barconfigs, configs) {
925 if (strcmp(current->id, bar_id) != 0)
934 /* If we did not find a config for the given ID, the reply will contain
935 * a null 'id' field. */
943 dump_bar_config(gen, config);
946 const unsigned char *payload;
948 y(get_buf, &payload, &length);
950 ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_BAR_CONFIG, payload);
955 * Callback for the YAJL parser (will be called when a string is parsed).
958 static int add_subscription(void *extra, const unsigned char *s,
960 ipc_client *client = extra;
962 DLOG("should add subscription to extra %p, sub %.*s\n", client, (int)len, s);
963 int event = client->num_events;
965 client->num_events++;
966 client->events = srealloc(client->events, client->num_events * sizeof(char *));
967 /* We copy the string because it is not null-terminated and strndup()
968 * is missing on some BSD systems */
969 client->events[event] = scalloc(len + 1, 1);
970 memcpy(client->events[event], s, len);
972 DLOG("client is now subscribed to:\n");
973 for (int i = 0; i < client->num_events; i++)
974 DLOG("event %s\n", client->events[i]);
981 * Subscribes this connection to the event types which were given as a JSON
982 * serialized array in the payload field of the message.
985 IPC_HANDLER(subscribe) {
988 ipc_client *current, *client = NULL;
990 /* Search the ipc_client structure for this connection */
991 TAILQ_FOREACH(current, &all_clients, clients) {
992 if (current->fd != fd)
999 if (client == NULL) {
1000 ELOG("Could not find ipc_client data structure for fd %d\n", fd);
1004 /* Setup the JSON parser */
1005 static yajl_callbacks callbacks = {
1006 .yajl_string = add_subscription,
1009 p = yalloc(&callbacks, (void *)client);
1010 stat = yajl_parse(p, (const unsigned char *)message, message_size);
1011 if (stat != yajl_status_ok) {
1013 err = yajl_get_error(p, true, (const unsigned char *)message,
1015 ELOG("YAJL parse error: %s\n", err);
1016 yajl_free_error(p, err);
1018 const char *reply = "{\"success\":false}";
1019 ipc_send_message(fd, strlen(reply), I3_IPC_REPLY_TYPE_SUBSCRIBE, (const uint8_t *)reply);
1024 const char *reply = "{\"success\":true}";
1025 ipc_send_message(fd, strlen(reply), I3_IPC_REPLY_TYPE_SUBSCRIBE, (const uint8_t *)reply);
1028 /* The index of each callback function corresponds to the numeric
1029 * value of the message type (see include/i3/ipc.h) */
1030 handler_t handlers[8] = {
1032 handle_get_workspaces,
1037 handle_get_bar_config,
1042 * Handler for activity on a client connection, receives a message from a
1045 * For now, the maximum message size is 2048. I’m not sure for what the
1046 * IPC interface will be used in the future, thus I’m not implementing a
1047 * mechanism for arbitrarily long messages, as it seems like overkill
1051 static void ipc_receive_message(EV_P_ struct ev_io *w, int revents) {
1052 uint32_t message_type;
1053 uint32_t message_length;
1054 uint8_t *message = NULL;
1056 int ret = ipc_recv_message(w->fd, &message_type, &message_length, &message);
1057 /* EOF or other error */
1059 /* Was this a spurious read? See ev(3) */
1060 if (ret == -1 && errno == EAGAIN) {
1065 /* If not, there was some kind of error. We don’t bother
1066 * and close the connection */
1069 /* Delete the client from the list of clients */
1070 ipc_client *current;
1071 TAILQ_FOREACH(current, &all_clients, clients) {
1072 if (current->fd != w->fd)
1075 for (int i = 0; i < current->num_events; i++)
1076 free(current->events[i]);
1077 /* We can call TAILQ_REMOVE because we break out of the
1078 * TAILQ_FOREACH afterwards */
1079 TAILQ_REMOVE(&all_clients, current, clients);
1084 ev_io_stop(EV_A_ w);
1088 DLOG("IPC: client disconnected\n");
1092 if (message_type >= (sizeof(handlers) / sizeof(handler_t)))
1093 DLOG("Unhandled message type: %d\n", message_type);
1095 handler_t h = handlers[message_type];
1096 h(w->fd, message, 0, message_length, message_type);
1103 * Handler for activity on the listening socket, meaning that a new client
1104 * has just connected and we should accept() him. Sets up the event handler
1105 * for activity on the new connection and inserts the file descriptor into
1106 * the list of clients.
1109 void ipc_new_client(EV_P_ struct ev_io *w, int revents) {
1110 struct sockaddr_un peer;
1111 socklen_t len = sizeof(struct sockaddr_un);
1113 if ((client = accept(w->fd, (struct sockaddr *)&peer, &len)) < 0) {
1121 /* Close this file descriptor on exec() */
1122 (void)fcntl(client, F_SETFD, FD_CLOEXEC);
1124 set_nonblock(client);
1126 struct ev_io *package = scalloc(1, sizeof(struct ev_io));
1127 ev_io_init(package, ipc_receive_message, client, EV_READ);
1128 ev_io_start(EV_A_ package);
1130 DLOG("IPC: new client connected on fd %d\n", w->fd);
1132 ipc_client *new = scalloc(1, sizeof(ipc_client));
1135 TAILQ_INSERT_TAIL(&all_clients, new, clients);
1139 * Creates the UNIX domain socket at the given path, sets it to non-blocking
1140 * mode, bind()s and listen()s on it.
1143 int ipc_create_socket(const char *filename) {
1146 FREE(current_socketpath);
1148 char *resolved = resolve_tilde(filename);
1149 DLOG("Creating IPC-socket at %s\n", resolved);
1150 char *copy = sstrdup(resolved);
1151 const char *dir = dirname(copy);
1152 if (!path_exists(dir))
1153 mkdirp(dir, DEFAULT_DIR_MODE);
1156 /* Unlink the unix domain socket before */
1159 if ((sockfd = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0) {
1165 (void)fcntl(sockfd, F_SETFD, FD_CLOEXEC);
1167 struct sockaddr_un addr;
1168 memset(&addr, 0, sizeof(struct sockaddr_un));
1169 addr.sun_family = AF_LOCAL;
1170 strncpy(addr.sun_path, resolved, sizeof(addr.sun_path) - 1);
1171 if (bind(sockfd, (struct sockaddr *)&addr, sizeof(struct sockaddr_un)) < 0) {
1177 set_nonblock(sockfd);
1179 if (listen(sockfd, 5) < 0) {
1185 current_socketpath = resolved;
1190 * Generates a json workspace event. Returns a dynamically allocated yajl
1191 * generator. Free with yajl_gen_free().
1193 yajl_gen ipc_marshal_workspace_event(const char *change, Con *current, Con *old) {
1194 setlocale(LC_NUMERIC, "C");
1195 yajl_gen gen = ygenalloc();
1203 if (current == NULL)
1206 dump_node(gen, current, false);
1212 dump_node(gen, old, false);
1216 setlocale(LC_NUMERIC, "");
1222 * For the workspace events we send, along with the usual "change" field, also
1223 * the workspace container in "current". For focus events, we send the
1224 * previously focused workspace in "old".
1226 void ipc_send_workspace_event(const char *change, Con *current, Con *old) {
1227 yajl_gen gen = ipc_marshal_workspace_event(change, current, old);
1229 const unsigned char *payload;
1231 y(get_buf, &payload, &length);
1233 ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, (const char *)payload);
1239 * For the window events we send, along the usual "change" field,
1240 * also the window container, in "container".
1242 void ipc_send_window_event(const char *property, Con *con) {
1243 DLOG("Issue IPC window %s event (con = %p, window = 0x%08x)\n",
1244 property, con, (con->window ? con->window->id : XCB_WINDOW_NONE));
1246 setlocale(LC_NUMERIC, "C");
1247 yajl_gen gen = ygenalloc();
1255 dump_node(gen, con, false);
1259 const unsigned char *payload;
1261 y(get_buf, &payload, &length);
1263 ipc_send_event("window", I3_IPC_EVENT_WINDOW, (const char *)payload);
1265 setlocale(LC_NUMERIC, "");
1269 * For the barconfig update events, we send the serialized barconfig.
1271 void ipc_send_barconfig_update_event(Barconfig *barconfig) {
1272 DLOG("Issue barconfig_update event for id = %s\n", barconfig->id);
1273 setlocale(LC_NUMERIC, "C");
1274 yajl_gen gen = ygenalloc();
1276 dump_bar_config(gen, barconfig);
1278 const unsigned char *payload;
1280 y(get_buf, &payload, &length);
1282 ipc_send_event("barconfig_update", I3_IPC_EVENT_BARCONFIG_UPDATE, (const char *)payload);
1284 setlocale(LC_NUMERIC, "");
1288 * For the binding events, we send the serialized binding struct.
1290 void ipc_send_binding_event(const char *event_type, Binding *bind) {
1291 DLOG("Issue IPC binding %s event (sym = %s, code = %d)\n", event_type, bind->symbol, bind->keycode);
1293 setlocale(LC_NUMERIC, "C");
1295 yajl_gen gen = ygenalloc();
1303 dump_binding(gen, bind);
1307 const unsigned char *payload;
1309 y(get_buf, &payload, &length);
1311 ipc_send_event("binding", I3_IPC_EVENT_BINDING, (const char *)payload);
1314 setlocale(LC_NUMERIC, "");