aboutsummaryrefslogtreecommitdiffstats
path: root/sway/ipc.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/ipc.c')
-rw-r--r--sway/ipc.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sway/ipc.c b/sway/ipc.c
index d13eb87f..7ff0df01 100644
--- a/sway/ipc.c
+++ b/sway/ipc.c
@@ -52,7 +52,8 @@ void ipc_init(void) {
52 52
53 ipc_sockaddr = ipc_user_sockaddr(); 53 ipc_sockaddr = ipc_user_sockaddr();
54 54
55 if (getenv("SWAYSOCK") != NULL) { 55 // We want to use socket name set by user, not existing socket from another sway instance.
56 if (getenv("SWAYSOCK") != NULL && access(getenv("SWAYSOCK"), F_OK) == -1) {
56 strncpy(ipc_sockaddr->sun_path, getenv("SWAYSOCK"), sizeof(ipc_sockaddr->sun_path)); 57 strncpy(ipc_sockaddr->sun_path, getenv("SWAYSOCK"), sizeof(ipc_sockaddr->sun_path));
57 } 58 }
58 59
@@ -66,7 +67,12 @@ void ipc_init(void) {
66 } 67 }
67 68
68 // Set i3 IPC socket path so that i3-msg works out of the box 69 // Set i3 IPC socket path so that i3-msg works out of the box
69 setenv("I3SOCK", ipc_sockaddr->sun_path, 1); 70 if (!getenv("I3SOCK")) {
71 setenv("I3SOCK", ipc_sockaddr->sun_path, 1);
72 }
73 if (!getenv("SWAYSOCK")) {
74 setenv("SWAYSOCK", ipc_sockaddr->sun_path, 1);
75 }
70 76
71 ipc_client_list = create_list(); 77 ipc_client_list = create_list();
72 78