mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-11 05:33:55 -04:00
Merge branch 'socket-path-uses-wayland-display-instead-of-xdg-session-id' into master
This commit is contained in:
commit
73b33afff2
7 changed files with 26 additions and 17 deletions
|
|
@ -40,6 +40,8 @@
|
||||||
* Configuration errors are no longer fatal; foot will start and print
|
* Configuration errors are no longer fatal; foot will start and print
|
||||||
an error inside the terminal (and of course still log errors on
|
an error inside the terminal (and of course still log errors on
|
||||||
stderr).
|
stderr).
|
||||||
|
* Default `--server` socket path to use `$WAYLAND_DISPLAY` instead of
|
||||||
|
`$XDG_SESSION_ID` (https://codeberg.org/dnkl/foot/issues/55).
|
||||||
|
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
||||||
13
client.c
13
client.c
|
|
@ -38,7 +38,7 @@ print_usage(const char *prog_name)
|
||||||
" --maximized start in maximized mode\n"
|
" --maximized start in maximized mode\n"
|
||||||
" --fullscreen start in fullscreen mode\n"
|
" --fullscreen start in fullscreen mode\n"
|
||||||
" --login-shell start shell as a login shell\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"
|
" --hold remain open after child process exits\n"
|
||||||
" -l,--log-colorize=[never|always|auto] enable/disable colorization of log output on stderr\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");
|
" -v,--version show the version number and quit\n");
|
||||||
|
|
@ -172,13 +172,16 @@ main(int argc, char *const *argv)
|
||||||
} else {
|
} else {
|
||||||
bool connected = false;
|
bool connected = false;
|
||||||
|
|
||||||
const char *xdg_session_id = getenv("XDG_SESSION_ID");
|
|
||||||
const char *xdg_runtime = getenv("XDG_RUNTIME_DIR");
|
const char *xdg_runtime = getenv("XDG_RUNTIME_DIR");
|
||||||
if (xdg_runtime != NULL) {
|
if (xdg_runtime != NULL) {
|
||||||
if (xdg_session_id == NULL)
|
const char *wayland_display = getenv("WAYLAND_DISPLAY");
|
||||||
xdg_session_id = "no-session";
|
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)
|
if (connect(fd, (const struct sockaddr *)&addr, sizeof(addr)) == 0)
|
||||||
connected = true;
|
connected = true;
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ _arguments \
|
||||||
'--maximized[start in maximized mode]' \
|
'--maximized[start in maximized mode]' \
|
||||||
'--fullscreen[start in fullscreen mode]' \
|
'--fullscreen[start in fullscreen mode]' \
|
||||||
'--login-shell[start shell as a login shell]' \
|
'--login-shell[start shell as a login shell]' \
|
||||||
'(-s --server-socket)'{-s,--server-socket}'[override the default path to the foot server socket (XDG_RUNTIME_DIR/foot.sock)]:server:_files' \
|
'(-s --server-socket)'{-s,--server-socket}'[override the default path to the foot server socket ($XDG_RUNTIME_DIR/foot-$WAYLAND_DISPLAY.sock)]:server:_files' \
|
||||||
'--hold[remain open after child process exits]' \
|
'--hold[remain open after child process exits]' \
|
||||||
'(-l --log-colorize)'{-l,--log-colorize}'[enable or disable colorization of log output on stderr]:logcolor:(never always auto)' \
|
'(-l --log-colorize)'{-l,--log-colorize}'[enable or disable colorization of log output on stderr]:logcolor:(never always auto)' \
|
||||||
'(-v --version)'{-v,--version}'[show the version number and quit]' \
|
'(-v --version)'{-v,--version}'[show the version number and quit]' \
|
||||||
|
|
|
||||||
13
config.c
13
config.c
|
|
@ -1188,16 +1188,19 @@ err:
|
||||||
static char *
|
static char *
|
||||||
get_server_socket_path(void)
|
get_server_socket_path(void)
|
||||||
{
|
{
|
||||||
const char *xdg_session_id = getenv("XDG_SESSION_ID");
|
|
||||||
const char *xdg_runtime = getenv("XDG_RUNTIME_DIR");
|
const char *xdg_runtime = getenv("XDG_RUNTIME_DIR");
|
||||||
if (xdg_runtime == NULL)
|
if (xdg_runtime == NULL)
|
||||||
return strdup("/tmp/foot.sock");
|
return strdup("/tmp/foot.sock");
|
||||||
|
|
||||||
if (xdg_session_id == NULL)
|
const char *wayland_display = getenv("WAYLAND_DISPLAY");
|
||||||
xdg_session_id = "no-session";
|
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);
|
char *path = malloc(strlen(xdg_runtime) + 1 + strlen("foot-.sock") + strlen(wayland_display) + 1);
|
||||||
sprintf(path, "%s/foot-%s.sock", xdg_runtime, xdg_session_id);
|
sprintf(path, "%s/foot-%s.sock", xdg_runtime, wayland_display);
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,13 +81,13 @@ arguments, to execute (instead of the default shell).
|
||||||
others with it.
|
others with it.
|
||||||
|
|
||||||
The default path is
|
The default path is
|
||||||
*$XDG\_RUNTIME\_DIR/foot-$XDG\_SESSION\_ID.sock*.
|
*$XDG\_RUNTIME\_DIR/foot-$WAYLAND\_DISPLAY.sock*.
|
||||||
|
|
||||||
If *$XDG_RUNTIME_DIR* is not set, the default path is instead
|
If *$XDG\_RUNTIME\_DIR* is not set, the default path is instead
|
||||||
*/tmp/foot.sock*.
|
*/tmp/foot.sock*.
|
||||||
|
|
||||||
If *$XDG_RUNTIME_DIR* is set, but *$XDG_SESSION_ID* is not, the
|
If *$XDG\_RUNTIME\_DIR* is set, but *$WAYLAND\_DISPLAY* is not,
|
||||||
default path is *$XDG_RUNTIME_DIR/foot-no-session.sock*.
|
the default path is *$XDG\_RUNTIME\_DIR/foot.sock*.
|
||||||
|
|
||||||
Note that if you change the default, you will also need to use the
|
Note that if you change the default, you will also need to use the
|
||||||
*--server-socket* option in *footclient*(1) and point it to your
|
*--server-socket* option in *footclient*(1) and point it to your
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,8 @@ arguments, to execute (instead of the default shell).
|
||||||
Start a login shell, by prepending a '-' to argv[0].
|
Start a login shell, by prepending a '-' to argv[0].
|
||||||
|
|
||||||
*-s*,*--server-socket*=_PATH_
|
*-s*,*--server-socket*=_PATH_
|
||||||
Connect to _PATH_ instead of _XDG\_RUNTIME\_DIR/foot.sock_.
|
Connect to _PATH_ instead of
|
||||||
|
*$XDG\_RUNTIME\_DIR/foot-$WAYLAND\_DISPLAY.sock*.
|
||||||
|
|
||||||
*--hold*
|
*--hold*
|
||||||
Remain open after child process exits.
|
Remain open after child process exits.
|
||||||
|
|
|
||||||
2
main.c
2
main.c
|
|
@ -56,7 +56,7 @@ print_usage(const char *prog_name)
|
||||||
" --login-shell start shell as a login shell\n"
|
" --login-shell start shell as a login shell\n"
|
||||||
" -g,--geometry=WIDTHxHEIGHT set initial width and height\n"
|
" -g,--geometry=WIDTHxHEIGHT set initial width and height\n"
|
||||||
" -s,--server[=PATH] run as a server (use 'footclient' to start terminals).\n"
|
" -s,--server[=PATH] run as a server (use 'footclient' to start terminals).\n"
|
||||||
" Without PATH, $XDG_RUNTIME_DIR/foot-$XDG_SESSION_ID.sock will be used.\n"
|
" Without PATH, $XDG_RUNTIME_DIR/foot-$WAYLAND_DISPLAY.sock will be used.\n"
|
||||||
" --hold remain open after child process exits\n"
|
" --hold remain open after child process exits\n"
|
||||||
" -p,--print-pid=FILE|FD print PID to file or FD (only applicable in server mode)\n"
|
" -p,--print-pid=FILE|FD print PID to file or FD (only applicable in server mode)\n"
|
||||||
" -l,--log-colorize=[never|always|auto] enable/disable colorization of log output on stderr\n"
|
" -l,--log-colorize=[never|always|auto] enable/disable colorization of log output on stderr\n"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue