aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Gautier <mg@max.gautier.name>2022-01-15 16:25:59 +0000
committerMax Gautier <mg@max.gautier.name>2022-02-26 15:09:30 +0000
commit1783f69cbd6291a30b9ab1f4daef9159b5dadd85 (patch)
tree2493bba12439837fc4ac23a30a56e4772290101d
parentMake foot able to receive a socket from its parent (diff)
Adding systemd unit files for socket activation
- Support for multiples concurrent instances, templated on WAYLAND_DISPLAY - Use standard input for the socket file descriptor (inetd style) - Always use the socket provided by systemd with the systemd user service - wayland-instance@.target is intended to be a special target a bit like graphical-session.target.
-rw-r--r--foot-server@.service.in13
-rw-r--r--foot-server@.socket5
-rw-r--r--meson.build19
3 files changed, 37 insertions, 0 deletions
diff --git a/foot-server@.service.in b/foot-server@.service.in
new file mode 100644
index 00000000..81c13bb4
--- /dev/null
+++ b/foot-server@.service.in
@@ -0,0 +1,13 @@
+[Service]
+ExecStart=@bindir@/foot --server=0
+Environment=WAYLAND_DISPLAY=%i
+NonBlocking=true
+StandardInput=socket
+
+[Unit]
+Requires=%N.socket
+Description=Foot terminal server mode for WAYLAND_DISPLAY=%i
+Documentation=man:foot(1)
+
+[Install]
+WantedBy=wayland-instance@.target
diff --git a/foot-server@.socket b/foot-server@.socket
new file mode 100644
index 00000000..71db51cb
--- /dev/null
+++ b/foot-server@.socket
@@ -0,0 +1,5 @@
+[Socket]
+ListenStream=%t/foot-%i.sock
+
+[Install]
+WantedBy=wayland-instance@.target
diff --git a/meson.build b/meson.build
index 30044f9e..8778927d 100644
--- a/meson.build
+++ b/meson.build
@@ -245,6 +245,25 @@ install_data(
'foot.desktop', 'foot-server.desktop', 'footclient.desktop',
install_dir: join_paths(get_option('datadir'), 'applications'))
+systemd = dependency('systemd', required: false)
+if systemd.found()
+
+ configuration = configuration_data()
+ configuration.set('bindir', join_paths(get_option('prefix'), get_option('bindir')))
+
+ systemd_units_dir = systemd.get_pkgconfig_variable('systemduserunitdir')
+ configure_file(
+ configuration: configuration,
+ input: 'foot-server@.service.in',
+ output: '@BASENAME@',
+ install_dir: systemd_units_dir
+ )
+
+ install_data(
+ 'foot-server@.socket',
+ install_dir: systemd_units_dir)
+endif
+
scdoc = dependency('scdoc', native: true, required: get_option('docs'))
if scdoc.found()
install_data(