Skip to content

Commit 1e24129

Browse files
SystemUpdate: Use systemd timer for initial and daily update check (#200)
Co-authored-by: Leonardo Lemos <leonardolemos@live.com>
1 parent c747331 commit 1e24129

5 files changed

Lines changed: 36 additions & 13 deletions

data/io.elementary.settings-daemon.gschema.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,6 @@
108108
<summary>When updates were last refreshed</summary>
109109
<description>When the cache was last refreshed and checked for updates in unix utc.</description>
110110
</key>
111-
<key type="x" name="refresh-interval">
112-
<default>86400</default>
113-
<summary>How often to check for updates</summary>
114-
<description>How often to check for updates in seconds.</description>
115-
</key>
116111
</schema>
117112

118113
<schema path="/io/elementary/settings-daemon/power/" id="io.elementary.settings-daemon.power">
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[Unit]
2+
Description=Check for system updates daily
3+
ConditionACPower=true
4+
After=network.target network-online.target systemd-networkd.service NetworkManager.service connman.service
5+
6+
[Service]
7+
Type=oneshot
8+
ExecStart=@busctl_path@ --user call io.elementary.settings-daemon /io/elementary/settings_daemon io.elementary.settings_daemon.SystemUpdate CheckForUpdates bb false true
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[Unit]
2+
Description=Check for system updates daily
3+
4+
[Timer]
5+
OnCalendar=daily
6+
OnStartupSec=60
7+
RandomizedDelaySec=60
8+
Persistent=true
9+
10+
[Install]
11+
WantedBy=timers.target

data/meson.build

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,16 @@ i18n.merge_file(
4747

4848
busctl_path = get_option('busctlpath')
4949
systemd_system_unit_dir = get_option('systemdsystemunitdir')
50+
systemd_user_unit_dir = get_option('systemduserunitdir')
5051

51-
if systemd_system_unit_dir != 'no'
52+
if systemd_system_unit_dir != 'no' and systemd_user_unit_dir != 'no'
5253
systemd = dependency('systemd')
5354
if systemd_system_unit_dir == ''
5455
systemd_system_unit_dir = systemd.get_variable('systemdsystemunitdir', pkgconfig_define: ['rootprefix', prefix])
5556
endif
57+
if systemd_user_unit_dir == ''
58+
systemd_user_unit_dir = systemd.get_variable('systemduserunitdir', pkgconfig_define: ['prefix', prefix])
59+
endif
5660
if busctl_path == ''
5761
busctl_path = systemd.get_variable('prefix') / 'bin' / 'busctl'
5862
endif
@@ -71,4 +75,16 @@ if systemd_system_unit_dir != 'no'
7175
meson.project_name() + '.check-for-firmware-updates.timer',
7276
install_dir: systemd_system_unit_dir
7377
)
78+
79+
configure_file(
80+
input: meson.project_name() + '.system-update.service.in',
81+
output: meson.project_name() + '.system-update.service',
82+
configuration: service_config,
83+
install_dir: systemd_user_unit_dir
84+
)
85+
86+
install_data(
87+
meson.project_name() + '.system-update.timer',
88+
install_dir: systemd_user_unit_dir
89+
)
7490
endif

src/Backends/SystemUpdate.vala

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,6 @@ public class SettingsDaemon.Backends.SystemUpdate : Object {
5858
} catch (Error e) {
5959
warning ("Couldn't determine last offline results: %s", e.message);
6060
}
61-
62-
check_for_updates.begin (false, true);
63-
64-
Timeout.add_seconds ((uint) settings.get_int64 ("refresh-interval"), () => {
65-
check_for_updates.begin (false, true);
66-
return Source.CONTINUE;
67-
});
6861
}
6962

7063
public async void check_for_updates (bool force, bool notify) throws DBusError, IOError {

0 commit comments

Comments
 (0)