From ea98281d0a33d732f122dd24686f19ace146572c Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Fri, 10 Apr 2020 01:48:41 -0700 Subject: [PATCH] Add D-Bus and systemd service files --- .../systemd/xdg-desktop-portal-wlr.service.in | 8 +++++ meson.build | 31 ++++++++++++++++++- meson_options.txt | 1 + ...desktop.impl.portal.desktop.wlr.service.in | 4 +++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 contrib/systemd/xdg-desktop-portal-wlr.service.in create mode 100644 meson_options.txt create mode 100644 org.freedesktop.impl.portal.desktop.wlr.service.in diff --git a/contrib/systemd/xdg-desktop-portal-wlr.service.in b/contrib/systemd/xdg-desktop-portal-wlr.service.in new file mode 100644 index 0000000..d4a83c6 --- /dev/null +++ b/contrib/systemd/xdg-desktop-portal-wlr.service.in @@ -0,0 +1,8 @@ +[Unit] +Description=Portal service (wlroots implementation) + +[Service] +Type=dbus +BusName=org.freedesktop.impl.portal.desktop.wlr +ExecStart=@libexecdir@/xdg-desktop-portal-wlr +Restart=on-failure diff --git a/meson.build b/meson.build index e2165c7..451db0d 100644 --- a/meson.build +++ b/meson.build @@ -3,7 +3,7 @@ project( 'c', version: '0.0.0', license: 'MIT', - meson_version: '>=0.46.0', + meson_version: '>=0.47.0', default_options: [ 'c_std=c11', 'warning_level=2', @@ -60,6 +60,35 @@ executable( ], include_directories: [inc], install: true, + install_dir: get_option('libexecdir'), +) + +conf_data = configuration_data() +conf_data.set('libexecdir', + join_paths(get_option('prefix'), get_option('libexecdir'))) +conf_data.set('systemd_service', '') + +systemd = dependency('systemd', required: get_option('systemd')) + +if systemd.found() + systemd_service_file = 'xdg-desktop-portal-wlr.service' + user_unit_dir = systemd.get_pkgconfig_variable('systemduserunitdir', + define_variable: ['prefix', get_option('prefix')]) + conf_data.set('systemd_service', 'SystemdService=' + systemd_service_file) + + configure_file( + configuration: conf_data, + input: 'contrib/systemd/' + systemd_service_file + '.in', + output: '@BASENAME@', + install_dir: user_unit_dir, + ) +endif + +configure_file( + configuration: conf_data, + input: 'org.freedesktop.impl.portal.desktop.wlr.service.in', + output: '@BASENAME@', + install_dir: join_paths(get_option('datadir'), 'dbus-1', 'services'), ) install_data( diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..5303abc --- /dev/null +++ b/meson_options.txt @@ -0,0 +1 @@ +option('systemd', type: 'feature', value: 'auto', description: 'Install systemd user service unit') diff --git a/org.freedesktop.impl.portal.desktop.wlr.service.in b/org.freedesktop.impl.portal.desktop.wlr.service.in new file mode 100644 index 0000000..2397e77 --- /dev/null +++ b/org.freedesktop.impl.portal.desktop.wlr.service.in @@ -0,0 +1,4 @@ +[D-BUS Service] +Name=org.freedesktop.impl.portal.desktop.wlr +Exec=@libexecdir@/xdg-desktop-portal-wlr +@systemd_service@