From 41ee397de2692890fcf2717500bd66af0f632fb3 Mon Sep 17 00:00:00 2001 From: LaserEyess Date: Sun, 23 Mar 2025 13:49:43 -0400 Subject: [PATCH] build: optionally install systemd service If using a systemd based distro, it is useful to have the service file installed so that it properly integrates with the service manager. Certain distros are carrying around patches that accomplish this. --- .builds/alpine.yml | 2 +- .builds/freebsd.yml | 2 +- fr.emersion.mako.service.in | 1 + meson.build | 14 ++++++++++++++ meson_options.txt | 1 + 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.builds/alpine.yml b/.builds/alpine.yml index 4b83c765..26f1e73c 100644 --- a/.builds/alpine.yml +++ b/.builds/alpine.yml @@ -13,7 +13,7 @@ sources: tasks: - setup: | cd mako - meson build/ -Dauto_features=enabled -Dsd-bus-provider=libelogind + meson build/ -Dauto_features=enabled -Dsd-bus-provider=libelogind -Dsystemd=disabled - build: | cd mako ninja -C build/ diff --git a/.builds/freebsd.yml b/.builds/freebsd.yml index 532fcef4..3f326286 100644 --- a/.builds/freebsd.yml +++ b/.builds/freebsd.yml @@ -15,7 +15,7 @@ sources: tasks: - setup: | cd mako - meson build/ -Dauto_features=enabled -Dsd-bus-provider=basu + meson build/ -Dauto_features=enabled -Dsd-bus-provider=basu -Dsystemd=disabled - build: | cd mako ninja -C build/ diff --git a/fr.emersion.mako.service.in b/fr.emersion.mako.service.in index db4bd8b8..4cc0080e 100644 --- a/fr.emersion.mako.service.in +++ b/fr.emersion.mako.service.in @@ -1,3 +1,4 @@ [D-BUS Service] Name=org.freedesktop.Notifications Exec=@bindir@/mako +@systemd_service@ diff --git a/meson.build b/meson.build index c3284e4c..503715a8 100644 --- a/meson.build +++ b/meson.build @@ -108,6 +108,20 @@ executable( conf_data = configuration_data() conf_data.set('bindir', get_option('prefix') / get_option('bindir')) +conf_data.set('systemd_service', '') + +systemd = dependency('systemd', required: get_option('systemd')) +if systemd.found() + service_file = 'mako.service' + user_unit_dir = systemd.get_variable(pkgconfig: 'systemduserunitdir', + pkgconfig_define: ['prefix', get_option('prefix')]) + conf_data.set('systemd_service', 'SystemdService=' + service_file) + + install_data( + 'contrib' / 'systemd' / service_file, + install_dir: user_unit_dir + ) +endif configure_file( configuration: conf_data, diff --git a/meson_options.txt b/meson_options.txt index 88e6c47e..2a5ddcc0 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -4,3 +4,4 @@ option('man-pages', type: 'feature', value: 'auto', description: 'Generate and i option('fish-completions', type: 'boolean', value: false, description: 'Install fish completions') option('zsh-completions', type: 'boolean', value: false, description: 'Install zsh completions') option('bash-completions', type: 'boolean', value: false, description: 'Install bash completions') +option('systemd', type: 'feature', value: 'auto', description: 'Install systemd user service unit')