diff --git a/data/io.elementary.settings-daemon.gschema.xml b/data/io.elementary.settings-daemon.gschema.xml
index f3ec639c..cd0b1a6c 100644
--- a/data/io.elementary.settings-daemon.gschema.xml
+++ b/data/io.elementary.settings-daemon.gschema.xml
@@ -108,11 +108,6 @@
When updates were last refreshed
When the cache was last refreshed and checked for updates in unix utc.
-
- 86400
- How often to check for updates
- How often to check for updates in seconds.
-
diff --git a/data/io.elementary.settings-daemon.system-update.service.in b/data/io.elementary.settings-daemon.system-update.service.in
new file mode 100644
index 00000000..d5a7cf93
--- /dev/null
+++ b/data/io.elementary.settings-daemon.system-update.service.in
@@ -0,0 +1,8 @@
+[Unit]
+Description=Check for system updates daily
+ConditionACPower=true
+After=network.target network-online.target systemd-networkd.service NetworkManager.service connman.service
+
+[Service]
+Type=oneshot
+ExecStart=@busctl_path@ --user call io.elementary.settings-daemon /io/elementary/settings_daemon io.elementary.settings_daemon.SystemUpdate CheckForUpdates bb false true
diff --git a/data/io.elementary.settings-daemon.system-update.timer b/data/io.elementary.settings-daemon.system-update.timer
new file mode 100644
index 00000000..26018b0e
--- /dev/null
+++ b/data/io.elementary.settings-daemon.system-update.timer
@@ -0,0 +1,11 @@
+[Unit]
+Description=Check for system updates daily
+
+[Timer]
+OnCalendar=daily
+OnStartupSec=60
+RandomizedDelaySec=60
+Persistent=true
+
+[Install]
+WantedBy=timers.target
diff --git a/data/meson.build b/data/meson.build
index 0b846b39..22c31034 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -47,12 +47,16 @@ i18n.merge_file(
busctl_path = get_option('busctlpath')
systemd_system_unit_dir = get_option('systemdsystemunitdir')
+systemd_user_unit_dir = get_option('systemduserunitdir')
-if systemd_system_unit_dir != 'no'
+if systemd_system_unit_dir != 'no' and systemd_user_unit_dir != 'no'
systemd = dependency('systemd')
if systemd_system_unit_dir == ''
systemd_system_unit_dir = systemd.get_variable('systemdsystemunitdir', pkgconfig_define: ['rootprefix', prefix])
endif
+ if systemd_user_unit_dir == ''
+ systemd_user_unit_dir = systemd.get_variable('systemduserunitdir', pkgconfig_define: ['prefix', prefix])
+ endif
if busctl_path == ''
busctl_path = systemd.get_variable('prefix') / 'bin' / 'busctl'
endif
@@ -71,4 +75,16 @@ if systemd_system_unit_dir != 'no'
meson.project_name() + '.check-for-firmware-updates.timer',
install_dir: systemd_system_unit_dir
)
+
+ configure_file(
+ input: meson.project_name() + '.system-update.service.in',
+ output: meson.project_name() + '.system-update.service',
+ configuration: service_config,
+ install_dir: systemd_user_unit_dir
+ )
+
+ install_data(
+ meson.project_name() + '.system-update.timer',
+ install_dir: systemd_user_unit_dir
+ )
endif
diff --git a/src/Backends/SystemUpdate.vala b/src/Backends/SystemUpdate.vala
index 1ee36d61..4a110f47 100644
--- a/src/Backends/SystemUpdate.vala
+++ b/src/Backends/SystemUpdate.vala
@@ -58,13 +58,6 @@ public class SettingsDaemon.Backends.SystemUpdate : Object {
} catch (Error e) {
warning ("Couldn't determine last offline results: %s", e.message);
}
-
- check_for_updates.begin (false, true);
-
- Timeout.add_seconds ((uint) settings.get_int64 ("refresh-interval"), () => {
- check_for_updates.begin (false, true);
- return Source.CONTINUE;
- });
}
public async void check_for_updates (bool force, bool notify) throws DBusError, IOError {