diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-08-02 11:10:31 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-08-02 11:10:31 +0000 |
| commit | 5e26d3ef470bc1129e7fb442334e34dcbb045d12 (patch) | |
| tree | ef10126fed29cb0c7f2bc145eaf36557077d7a1c /client.c | |
| parent | main: 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 'client.c')
| -rw-r--r-- | client.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -38,7 +38,7 @@ print_usage(const char *prog_name) " --maximized start in maximized mode\n" " --fullscreen start in fullscreen mode\n" " --login-shell start shell as a login shell\n" - " -s,--server-socket=PATH path to the server UNIX domain socket (default=$XDG_RUNTIME_DIR/foot-$XDG_SESSION_ID.sock)\n" + " -s,--server-socket=PATH path to the server UNIX domain socket (default=$XDG_RUNTIME_DIR/foot-$WAYLAND_DISPLAY.sock)\n" " --hold remain open after child process exits\n" " -l,--log-colorize=[never|always|auto] enable/disable colorization of log output on stderr\n" " -v,--version show the version number and quit\n"); @@ -172,13 +172,16 @@ 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) { - if (xdg_session_id == NULL) - xdg_session_id = "no-session"; + const char *wayland_display = getenv("WAYLAND_DISPLAY"); + if (wayland_display != NULL) + snprintf(addr.sun_path, sizeof(addr.sun_path), + "%s/foot-%s.sock", xdg_runtime, wayland_display); + else + snprintf(addr.sun_path, sizeof(addr.sun_path), + "%s/foot.sock", xdg_runtime); - 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 |
