add libi3/ipc_connect, use it in i3-config-wizard, i3-input, i3bar
This commit is contained in:
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* vim:ts=8:expandtab
|
||||
*
|
||||
* i3 - an improved dynamic tiling window manager
|
||||
*
|
||||
* © 2009 Michael Stapelberg and contributors
|
||||
*
|
||||
* See file LICENSE for license information.
|
||||
*
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <unistd.h>
|
||||
#include <err.h>
|
||||
|
||||
/*
|
||||
* Connects to the i3 IPC socket and returns the file descriptor for the
|
||||
* socket. die()s if anything goes wrong.
|
||||
*
|
||||
*/
|
||||
int connect_ipc(char *socket_path) {
|
||||
int sockfd = socket(AF_LOCAL, SOCK_STREAM, 0);
|
||||
if (sockfd == -1)
|
||||
err(EXIT_FAILURE, "Could not create socket");
|
||||
|
||||
struct sockaddr_un addr;
|
||||
memset(&addr, 0, sizeof(struct sockaddr_un));
|
||||
addr.sun_family = AF_LOCAL;
|
||||
strcpy(addr.sun_path, socket_path);
|
||||
if (connect(sockfd, (const struct sockaddr*)&addr, sizeof(struct sockaddr_un)) < 0)
|
||||
err(EXIT_FAILURE, "Could not connect to i3");
|
||||
|
||||
return sockfd;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
#ifndef _IPC_H
|
||||
#define _IPC_H
|
||||
|
||||
int connect_ipc(char *socket_path);
|
||||
|
||||
#endif
|
@ -51,7 +51,6 @@
|
||||
while (0)
|
||||
|
||||
#include "xcb.h"
|
||||
#include "ipc.h"
|
||||
#include "libi3.h"
|
||||
|
||||
enum { STEP_WELCOME, STEP_GENERATE } current_step = STEP_WELCOME;
|
||||
@ -371,7 +370,7 @@ static void finish() {
|
||||
fclose(ks_config);
|
||||
|
||||
/* tell i3 to reload the config file */
|
||||
int sockfd = connect_ipc(socket_path);
|
||||
int sockfd = ipc_connect(socket_path);
|
||||
ipc_send_message(sockfd, strlen("reload"), 0, (uint8_t*)"reload");
|
||||
close(sockfd);
|
||||
|
||||
|
Reference in New Issue
Block a user