diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7249bc2..11a2c1a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,7 +23,7 @@ jobs: - name: Install Dependencies run: | apt update - apt install -y libgranite-dev meson valac + apt install -y libgranite-dev systemd-dev meson valac - name: Build env: DESTDIR: out diff --git a/README.md b/README.md index 969f993..51c9a31 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ You'll need the following dependencies: libgranite-dev >= 6.0.0 libgtk3-dev + systemd-dev meson valac diff --git a/data/bluetooth-daemon.desktop b/data/bluetooth-daemon.desktop deleted file mode 100644 index ef434d9..0000000 --- a/data/bluetooth-daemon.desktop +++ /dev/null @@ -1,12 +0,0 @@ -[Desktop Entry] -Name=Bluetooth Daemon -Comment=Send and receive files via Bluetooth -Exec=io.elementary.bluetooth -s -Icon=io.elementary.bluetooth -Type=Application -NoDisplay=true -Categories=System; -X-GNOME-Autostart-Notify=false -X-GNOME-AutoRestart=true -X-GNOME-Autostart-enabled=true -OnlyShowIn=Pantheon; diff --git a/data/bluetooth.service.in b/data/bluetooth.service.in new file mode 100644 index 0000000..d4ef9b4 --- /dev/null +++ b/data/bluetooth.service.in @@ -0,0 +1,12 @@ +[Unit] +Description=Bluetooth Daemon +After=gnome-session-initialized.target + +[Install] +WantedBy=gnome-session-initialized.target + +[Service] +Type=exec +ExecStart=@bindir@/io.elementary.bluetooth -s +Restart=on-failure +Slice=session.slice diff --git a/data/meson.build b/data/meson.build index 9335494..d910a4a 100644 --- a/data/meson.build +++ b/data/meson.build @@ -13,11 +13,24 @@ foreach i : icon_sizes ) endforeach -install_data( - 'bluetooth-daemon.desktop', - rename: meson.project_name() + '.desktop', - install_dir: get_option('sysconfdir') / 'xdg' / 'autostart' -) +systemd_user_unit_dir = get_option('systemduserunitdir') +if systemd_user_unit_dir != 'no' + systemd_dep = dependency ('systemd') + + if systemd_user_unit_dir == '' + systemd_user_unit_dir = systemd_dep.get_variable('systemduserunitdir', pkgconfig_define: ['prefix', prefix]) + endif + + service_config = configuration_data() + service_config.set('bindir', bindir) + + configure_file( + input: 'bluetooth.service.in', + output: meson.project_name() + '.service', + configuration: service_config, + install_dir: systemd_user_unit_dir + ) +endif i18n.merge_file( input: 'bluetooth.desktop', diff --git a/meson.build b/meson.build index d187293..4cf94a8 100644 --- a/meson.build +++ b/meson.build @@ -10,6 +10,9 @@ add_global_arguments('-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()), lan gnome = import('gnome') i18n = import('i18n') +prefix = get_option('prefix') +bindir = prefix / get_option('bindir') + granite_dep = dependency ('granite') gtk_dep = dependency ('gtk+-3.0') posix_dep = meson.get_compiler('vala').find_library('posix') diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000..d1195c4 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1 @@ +option('systemduserunitdir', type: 'string', value: '', description: 'custom directory for systemd user units, or \'no\' to disable')