From 67985e903188a464e602d04f9ed218bd397f5ab1 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Fri, 5 Jan 2018 22:32:51 +0100 Subject: sway: change all sway_log to wlr_log --- common/ipc-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common/ipc-client.c') diff --git a/common/ipc-client.c b/common/ipc-client.c index 1ab6627b..582c5e86 100644 --- a/common/ipc-client.c +++ b/common/ipc-client.c @@ -79,7 +79,7 @@ struct ipc_response *ipc_recv_response(int socketfd) { error_2: free(response); error_1: - sway_log(L_ERROR, "Unable to allocate memory for IPC response"); + wlr_log(L_ERROR, "Unable to allocate memory for IPC response"); return NULL; } -- cgit v1.2.3 From 382e8af418a7e1b8cf93d3398509b93c6874cb0d Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 28 Mar 2018 21:21:36 -0400 Subject: Allow sway IPC clients to fall back to i3 socket --- common/ipc-client.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'common/ipc-client.c') diff --git a/common/ipc-client.c b/common/ipc-client.c index 582c5e86..117e9910 100644 --- a/common/ipc-client.c +++ b/common/ipc-client.c @@ -1,4 +1,4 @@ -#define _POSIX_C_SOURCE 2 +#define _POSIX_C_SOURCE 200809L #include #include #include @@ -14,13 +14,31 @@ static const char ipc_magic[] = {'i', '3', '-', 'i', 'p', 'c'}; static const size_t ipc_header_size = sizeof(ipc_magic)+8; char *get_socketpath(void) { - FILE *fp = popen("sway --get-socketpath", "r"); - if (!fp) { - return NULL; + const char *swaysock = getenv("SWAYSOCK"); + if (swaysock) { + return strdup(swaysock); } - char *line = read_line(fp); - pclose(fp); - return line; + FILE *fp = popen("sway --get-socketpath 2>/dev/null", "r"); + if (fp) { + char *line = read_line(fp); + pclose(fp); + if (line && *line) { + return line; + } + } + const char *i3sock = getenv("I3SOCK"); + if (i3sock) { + return strdup(i3sock); + } + fp = popen("i3 --get-socketpath 2>/dev/null", "r"); + if (fp) { + char *line = read_line(fp); + pclose(fp); + if (line && *line) { + return line; + } + } + return NULL; } int ipc_open_socket(const char *socket_path) { -- cgit v1.2.3