From 8ab402b25249cc9659bcd07823b0a4f101f5fec2 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 9 Mar 2020 18:47:10 +0100 Subject: server/client: add XDG_SESSION_ID to the default socket path This allows multiple foot servers to run in multiple sessions. --- config.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'config.c') diff --git a/config.c b/config.c index 46056567..4f9cde4d 100644 --- a/config.c +++ b/config.c @@ -561,12 +561,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 = ""; + + 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; } -- cgit v1.3