From 1d472564c9d984272e87cee0054821ec45c02270 Mon Sep 17 00:00:00 2001 From: Ryo Nakano Date: Thu, 19 Jun 2025 20:49:06 +0900 Subject: [PATCH 1/4] SystemUpdate: Use systemd timer for initial and daily update check --- data/io.elementary.settings-daemon.gschema.xml | 5 ----- ...ementary.settings-daemon.system-update.service.in | 8 ++++++++ ...io.elementary.settings-daemon.system-update.timer | 10 ++++++++++ data/meson.build | 12 ++++++++++++ src/Backends/SystemUpdate.vala | 7 ------- 5 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 data/io.elementary.settings-daemon.system-update.service.in create mode 100644 data/io.elementary.settings-daemon.system-update.timer 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..14a79d16 --- /dev/null +++ b/data/io.elementary.settings-daemon.system-update.timer @@ -0,0 +1,10 @@ +[Unit] +Description=Check for system updates daily + +[Timer] +OnCalendar=daily +OnStartupSec=60 +Persistent=true + +[Install] +WantedBy=timers.target diff --git a/data/meson.build b/data/meson.build index 0b846b39..e2d8294f 100644 --- a/data/meson.build +++ b/data/meson.build @@ -71,4 +71,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_system_unit_dir + ) + + install_data( + meson.project_name() + '.system-update.timer', + install_dir: systemd_system_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 { From 8997b5f202775e6dd38efa64ea7b4b56473662f7 Mon Sep 17 00:00:00 2001 From: Ryo Nakano Date: Thu, 19 Jun 2025 21:11:12 +0900 Subject: [PATCH 2/4] Install as user service --- data/meson.build | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/data/meson.build b/data/meson.build index e2d8294f..bbbfd5a0 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_systemduserunitdir != '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 @@ -76,11 +80,11 @@ if systemd_system_unit_dir != 'no' input: meson.project_name() + '.system-update.service.in', output: meson.project_name() + '.system-update.service', configuration: service_config, - install_dir: systemd_system_unit_dir + install_dir: systemd_user_unit_dir ) install_data( meson.project_name() + '.system-update.timer', - install_dir: systemd_system_unit_dir + install_dir: systemd_user_unit_dir ) endif From a0cb07f4a07b29005ce13d98a9e321f727afef53 Mon Sep 17 00:00:00 2001 From: Ryo Nakano Date: Thu, 19 Jun 2025 21:14:07 +0900 Subject: [PATCH 3/4] Fix typo --- data/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/meson.build b/data/meson.build index bbbfd5a0..22c31034 100644 --- a/data/meson.build +++ b/data/meson.build @@ -49,7 +49,7 @@ 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' and systemd_systemduserunitdir != '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]) From 80e6a1325338cbbb33d3370e1493b7b15560ab6d Mon Sep 17 00:00:00 2001 From: Ryo Nakano Date: Sun, 22 Jun 2025 08:26:35 +0900 Subject: [PATCH 4/4] Set RandomizedDelaySec to prevent performance spikes --- data/io.elementary.settings-daemon.system-update.timer | 1 + 1 file changed, 1 insertion(+) diff --git a/data/io.elementary.settings-daemon.system-update.timer b/data/io.elementary.settings-daemon.system-update.timer index 14a79d16..26018b0e 100644 --- a/data/io.elementary.settings-daemon.system-update.timer +++ b/data/io.elementary.settings-daemon.system-update.timer @@ -4,6 +4,7 @@ Description=Check for system updates daily [Timer] OnCalendar=daily OnStartupSec=60 +RandomizedDelaySec=60 Persistent=true [Install]