aboutsummaryrefslogtreecommitdiff
path: root/sway/ipc.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2015-11-13 08:17:35 -0500
committerDrew DeVault <sir@cmpwn.com>2015-11-13 08:17:35 -0500
commit1011957465dd9a6e6d29ecb4dc07f0cb8af50ea5 (patch)
tree6c6c7fbb0caa7333e3bf80de6a00c346000cb0c2 /sway/ipc.c
parent38b18d460a21c8395b3849b15ff7963e3d201f94 (diff)
parentf3fc48f69210a90f599d784df9db60840fcfc9b7 (diff)
Merge branch 'master' of github.com:SirCmpwn/sway
Diffstat (limited to 'sway/ipc.c')
-rw-r--r--sway/ipc.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/sway/ipc.c b/sway/ipc.c
index 8935147d..d13eb87f 100644
--- a/sway/ipc.c
+++ b/sway/ipc.c
@@ -94,14 +94,15 @@ struct sockaddr_un *ipc_user_sockaddr(void) {
}
ipc_sockaddr->sun_family = AF_UNIX;
-
int path_size = sizeof(ipc_sockaddr->sun_path);
- // Without logind:
- int allocating_path_size = snprintf(ipc_sockaddr->sun_path, path_size,
- "/tmp/sway-ipc.%i.%i.sock", getuid(), getpid());
-
- if (allocating_path_size >= path_size) {
+ // Env var typically set by logind, e.g. "/run/user/<user-id>"
+ const char *dir = getenv("XDG_RUNTIME_DIR");
+ if (!dir) {
+ dir = "/tmp";
+ }
+ if (path_size <= snprintf(ipc_sockaddr->sun_path, path_size,
+ "%s/sway-ipc.%i.%i.sock", dir, getuid(), getpid())) {
sway_abort("socket path won't fit into ipc_sockaddr->sun_path");
}