aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authorS. Christoffer Eliesen <christoffer@eliesen.no>2015-11-12 17:19:58 +0100
committerS. Christoffer Eliesen <christoffer@eliesen.no>2015-11-13 14:07:18 +0100
commit253204efb9517181c386036cae5ea5595a26b55a (patch)
tree6c6c7fbb0caa7333e3bf80de6a00c346000cb0c2 /sway
parent5c3f40111a3c5ddfdd66bfda153c7962db674ed0 (diff)
downloadsway-253204efb9517181c386036cae5ea5595a26b55a.tar.xz
ipc: Put socket into proper user runtime dir.
Diffstat (limited to 'sway')
-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");
}