Merge branch 'systemd-units-socket-activation'

This commit is contained in:
Daniel Eklöf 2023-07-21 08:13:51 +02:00
commit 098f0aafd4
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
8 changed files with 41 additions and 22 deletions

View file

@ -53,9 +53,16 @@
* Starlight theme (the default theme) updated to [V4][starlight-v4]
* Background transparency (alpha) is now disabled in fullscreened
windows ([#1416][1416]).
* Foot server systemd units now use the standard
graphical-session.target ([#1281][1281]).
* If `$XDG_RUNTIME_DIR/foot-$WAYLAND_DISPLAY.sock` does not exist,
`footclient` now tries `$XDG_RUNTIME_DIR/foot.sock`, then
`/tmp/foot.sock`, even if `$WAYLAND_DISPLAY` and/or
`$XDG_RUNTIME_DIR` are defined ([#1281][1281]).
[starlight-v4]: https://github.com/CosmicToast/starlight/blob/v4/CHANGELOG.md#v4
[1416]: https://codeberg.org/dnkl/foot/issues/1416
[1281]: https://codeberg.org/dnkl/foot/pulls/1281
### Deprecated

View file

@ -374,16 +374,19 @@ main(int argc, char *const *argv)
const char *xdg_runtime = getenv("XDG_RUNTIME_DIR");
if (xdg_runtime != NULL) {
const char *wayland_display = getenv("WAYLAND_DISPLAY");
if (wayland_display != NULL)
if (wayland_display != NULL) {
snprintf(addr.sun_path, sizeof(addr.sun_path),
"%s/foot-%s.sock", xdg_runtime, wayland_display);
else
connected = (connect(fd, (const struct sockaddr *)&addr, sizeof(addr)) == 0);
}
if (!connected) {
LOG_WARN("%s: failed to connect, will now try %s/foot.sock",
addr.sun_path, xdg_runtime);
snprintf(addr.sun_path, sizeof(addr.sun_path),
"%s/foot.sock", xdg_runtime);
if (connect(fd, (const struct sockaddr *)&addr, sizeof(addr)) == 0)
connected = true;
else
connected = (connect(fd, (const struct sockaddr *)&addr, sizeof(addr)) == 0);
}
if (!connected)
LOG_WARN("%s: failed to connect, will now try /tmp/foot.sock", addr.sun_path);
}

View file

@ -121,14 +121,14 @@ the foot command line
of a socket provided by a supervision daemon (such as systemd or s6), and
use that socket as it's own.
Two systemd units (foot-server@.{service,socket}) are provided to use that
feature with systemd. They need to be instantiated with the value of
$WAYLAND_DISPLAY (multiples instances can co-exists).
Two systemd units (foot-server.{service,socket}) are provided to use that
feature with systemd. To use socket activation, only enable the
socket unit.
Note that starting *foot --server* as a systemd service will use
the environment of the systemd user instance; thus, if you need specific
environment variables, you'll need to import them using *systemctl --user
import-environment* or use a drop-in for the foot-server service.
the environment of the systemd user instance; thus, you'll need
to import *$WAYLAND_DISPLAY* in it using *systemctl --user
import-environment WAYLAND_DISPLAY*.
*-H*,*--hold*
Remain open after child process exits.

View file

@ -146,6 +146,11 @@ terminfo entries manually, by copying *foot* and *foot-direct* to
Used to construct the default _PATH_ for the *--server-socket*
option, when no explicit argument is given (see above).
If the socket at default _PATH_ does not exist, *footclient* will
fallback to the less specific path, with the following priority:
*$XDG\_RUNTIME\_DIR/foot-$WAYLAND\_DISPLAY.sock*,
*$XDG\_RUNTIME\_DIR/foot.sock*, */tmp/foot.sock*.
## Variables set in the child process
*TERM*

View file

@ -1,13 +1,13 @@
[Service]
ExecStart=@bindir@/foot --server=3
Environment=WAYLAND_DISPLAY=%i
UnsetEnvironment=LISTEN_PID LISTEN_FDS LISTEN_FDNAMES
NonBlocking=true
[Unit]
Requires=%N.socket
Description=Foot terminal server mode for WAYLAND_DISPLAY=%i
Description=Foot terminal server mode
Documentation=man:foot(1)
PartOf=graphical-session.target
[Install]
WantedBy=wayland-instance@.target
WantedBy=graphical-session.target

9
foot-server.socket Normal file
View file

@ -0,0 +1,9 @@
[Socket]
ListenStream=%t/foot.sock
[Unit]
PartOf=graphical-session.target
ConditionEnvironment=WAYLAND_DISPLAY
[Install]
WantedBy=graphical-session.target

View file

@ -1,5 +0,0 @@
[Socket]
ListenStream=%t/foot-%i.sock
[Install]
WantedBy=wayland-instance@.target

View file

@ -329,13 +329,13 @@ if systemd.found() or custom_systemd_units_dir != ''
configure_file(
configuration: configuration,
input: 'foot-server@.service.in',
input: 'foot-server.service.in',
output: '@BASENAME@',
install_dir: systemd_units_dir
)
install_data(
'foot-server@.socket',
'foot-server.socket',
install_dir: systemd_units_dir)
endif