#include "i3/ipc.h"
+extern char *current_socketpath;
+
typedef struct ipc_client {
int fd;
#include "all.h"
+char *current_socketpath = NULL;
+
/* Shorter names for all those yajl_gen_* functions */
#define y(x, ...) yajl_gen_ ## x (gen, ##__VA_ARGS__)
#define ystr(str) yajl_gen_string(gen, (unsigned char*)str, strlen(str))
int ipc_create_socket(const char *filename) {
int sockfd;
+ FREE(current_socketpath);
+ current_socketpath = NULL;
+
char *resolved = resolve_tilde(filename);
DLOG("Creating IPC-socket at %s\n", resolved);
char *copy = sstrdup(resolved);
return -1;
}
- free(resolved);
set_nonblock(sockfd);
if (listen(sockfd, 5) < 0) {
perror("listen()");
+ free(resolved);
return -1;
}
+ current_socketpath = resolved;
return sockfd;
}
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_SUPPORTING_WM_CHECK, A_WINDOW, 32, 1, &root);
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A__NET_WM_NAME, A_UTF8_STRING, 8, strlen("i3"), "i3");
- /* Set up i3 specific atoms like I3_SOCKET_PATH and I3_CONFIG_PATH */
- x_set_i3_atoms();
-
keysyms = xcb_key_symbols_alloc(conn);
xcb_get_numlock_mask(conn);
}
}
+ /* Set up i3 specific atoms like I3_SOCKET_PATH and I3_CONFIG_PATH */
+ x_set_i3_atoms();
+
struct ev_io *xcb_watcher = scalloc(sizeof(struct ev_io));
struct ev_io *xkb = scalloc(sizeof(struct ev_io));
struct ev_check *xcb_check = scalloc(sizeof(struct ev_check));
*/
void x_set_i3_atoms() {
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A_I3_SOCKET_PATH, A_UTF8_STRING, 8,
- (config.ipc_socket_path != NULL ? strlen(config.ipc_socket_path) : 0),
- config.ipc_socket_path);
+ (current_socketpath == NULL ? 0 : strlen(current_socketpath)),
+ current_socketpath);
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, root, A_I3_CONFIG_PATH, A_UTF8_STRING, 8,
strlen(current_configpath), current_configpath);
}