aboutsummaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-08-02 11:10:31 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-08-02 11:10:31 +0000
commit5e26d3ef470bc1129e7fb442334e34dcbb045d12 (patch)
treeef10126fed29cb0c7f2bc145eaf36557077d7a1c /config.c
parentmain: update --help with correct default path for -s,--server (diff)
server/client: use $WAYLAND_DISPLAY instead of $XDG_SESSION_ID in default socket path
Foot is a Wayland client and cannot be run outside of a Wayland session. As such, it makes more sense to use $WAYLAND_SESSION instead of $XDG_SESSION_ID in the default socket path since this makes it clearer which Wayland session we belong to. Closes #55.
Diffstat (limited to 'config.c')
-rw-r--r--config.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/config.c b/config.c
index 50bf8a19..2976c6a4 100644
--- a/config.c
+++ b/config.c
@@ -1188,16 +1188,19 @@ 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");
- if (xdg_session_id == NULL)
- xdg_session_id = "no-session";
+ const char *wayland_display = getenv("WAYLAND_DISPLAY");
+ if (wayland_display == NULL) {
+ char *path = malloc(strlen(xdg_runtime) + 1 + strlen("foot.sock") + 1);
+ sprintf(path, "%s/foot.sock", xdg_runtime);
+ return path;
+ }
- 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);
+ char *path = malloc(strlen(xdg_runtime) + 1 + strlen("foot-.sock") + strlen(wayland_display) + 1);
+ sprintf(path, "%s/foot-%s.sock", xdg_runtime, wayland_display);
return path;
}