aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client.c5
-rw-r--r--config.c8
2 files changed, 10 insertions, 3 deletions
diff --git a/client.c b/client.c
index 29b4e3b2..30271c86 100644
--- a/client.c
+++ b/client.c
@@ -135,10 +135,13 @@ main(int argc, char *const *argv)
} else {
bool connected = false;
+ const char *xdg_session_id = getenv("XDG_SESSION_ID");
const char *xdg_runtime = getenv("XDG_RUNTIME_DIR");
if (xdg_runtime != NULL) {
- snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/foot.sock", xdg_runtime);
+ if (xdg_session_id == NULL)
+ xdg_session_id = "<no-session>";
+ snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/foot-%s.sock", xdg_runtime, xdg_session_id);
if (connect(fd, (const struct sockaddr *)&addr, sizeof(addr)) == 0)
connected = true;
else
diff --git a/config.c b/config.c
index 5ea035df..dc4917b1 100644
--- a/config.c
+++ b/config.c
@@ -567,12 +567,16 @@ err:
static char *
get_server_socket_path(void)
{
+ const char *xdg_session_id = getenv("XDG_SESSION_ID");
const char *xdg_runtime = getenv("XDG_RUNTIME_DIR");
if (xdg_runtime == NULL)
return strdup("/tmp/foot.sock");
- char *path = malloc(strlen(xdg_runtime) + 1 + strlen("foot.sock") + 1);
- sprintf(path, "%s/foot.sock", xdg_runtime);
+ if (xdg_session_id == NULL)
+ xdg_session_id = "<no-session>";
+
+ char *path = malloc(strlen(xdg_runtime) + 1 + strlen("foot-.sock") + strlen(xdg_session_id) + 1);
+ sprintf(path, "%s/foot-%s.sock", xdg_runtime, xdg_session_id);
return path;
}