4 * i3 - an improved dynamic tiling window manager
6 * © 2009 Michael Stapelberg and contributors
8 * See file LICENSE for license information.
14 #include <sys/socket.h>
20 * Connects to the i3 IPC socket and returns the file descriptor for the
21 * socket. die()s if anything goes wrong.
24 int connect_ipc(char *socket_path) {
25 int sockfd = socket(AF_LOCAL, SOCK_STREAM, 0);
27 err(EXIT_FAILURE, "Could not create socket");
29 struct sockaddr_un addr;
30 memset(&addr, 0, sizeof(struct sockaddr_un));
31 addr.sun_family = AF_LOCAL;
32 strcpy(addr.sun_path, socket_path);
33 if (connect(sockfd, (const struct sockaddr*)&addr, sizeof(struct sockaddr_un)) < 0)
34 err(EXIT_FAILURE, "Could not connect to i3");