mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-15 05:33:58 -04:00
server/client: add XDG_SESSION_ID to the default socket path
This allows multiple foot servers to run in multiple sessions.
This commit is contained in:
parent
9e3a68d6e7
commit
8ab402b252
2 changed files with 10 additions and 3 deletions
8
config.c
8
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 = "<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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue