aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2023-07-21 06:13:51 +0000
committerDaniel Eklöf <daniel@ekloef.se>2023-07-21 06:13:51 +0000
commit098f0aafd46cf512515b1d94e7cd3f2ce371faec (patch)
tree997a78e4efefeece0584855a728612a03d5421e8
parentvt: improve handling of HTS (diff)
parentChangelog: standard system target + footclient fallback (diff)
Merge branch 'systemd-units-socket-activation'
-rw-r--r--CHANGELOG.md7
-rw-r--r--client.c15
-rw-r--r--doc/foot.1.scd12
-rw-r--r--doc/footclient.1.scd5
-rw-r--r--foot-server.service.in (renamed from foot-server@.service.in)6
-rw-r--r--foot-server.socket9
-rw-r--r--foot-server@.socket5
-rw-r--r--meson.build4
8 files changed, 41 insertions, 22 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7ef784f2..29380684 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/client.c b/client.c
index 99c7c1e8..41be68a9 100644
--- a/client.c
+++ b/client.c
@@ -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);
}
diff --git a/doc/foot.1.scd b/doc/foot.1.scd
index 770c7f32..3da6fd7e 100644
--- a/doc/foot.1.scd
+++ b/doc/foot.1.scd
@@ -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.
diff --git a/doc/footclient.1.scd b/doc/footclient.1.scd
index 1464700c..7d89b9ed 100644
--- a/doc/footclient.1.scd
+++ b/doc/footclient.1.scd
@@ -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*
diff --git a/foot-server@.service.in b/foot-server.service.in
index c40bb454..47b81267 100644
--- a/foot-server@.service.in
+++ b/foot-server.service.in
@@ -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
diff --git a/foot-server.socket b/foot-server.socket
new file mode 100644
index 00000000..997e4363
--- /dev/null
+++ b/foot-server.socket
@@ -0,0 +1,9 @@
+[Socket]
+ListenStream=%t/foot.sock
+
+[Unit]
+PartOf=graphical-session.target
+ConditionEnvironment=WAYLAND_DISPLAY
+
+[Install]
+WantedBy=graphical-session.target
diff --git a/foot-server@.socket b/foot-server@.socket
deleted file mode 100644
index 71db51cb..00000000
--- a/foot-server@.socket
+++ /dev/null
@@ -1,5 +0,0 @@
-[Socket]
-ListenStream=%t/foot-%i.sock
-
-[Install]
-WantedBy=wayland-instance@.target
diff --git a/meson.build b/meson.build
index 1a00153c..cdccfa7e 100644
--- a/meson.build
+++ b/meson.build
@@ -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