From 9a3b19091930d299ae4cac5bf2de16154924edd6 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Wed, 12 Jan 2022 19:07:53 +0100 Subject: [PATCH 01/14] Add fwupd as dependency --- README.md | 3 ++- meson.build | 1 + src/meson.build | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8a009da2..c3e552b1 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,9 @@ You'll need the following dependencies: * gobject-2.0 * libaccountsservice-dev * libdbus-1-dev -* libgranite-dev +* libfwupd-dev * libgeoclue-2-dev +* libgranite-dev * meson * valac diff --git a/meson.build b/meson.build index c0befceb..6331386c 100644 --- a/meson.build +++ b/meson.build @@ -4,6 +4,7 @@ project('io.elementary.settings-daemon', license: 'GPL3', ) +fwupd = dependency('fwupd') gio_dep = dependency ('gio-2.0') glib_dep = dependency('glib-2.0') granite_dep = dependency('granite', version: '>= 5.3.0') diff --git a/src/meson.build b/src/meson.build index 7c726d97..94aca829 100644 --- a/src/meson.build +++ b/src/meson.build @@ -14,6 +14,7 @@ executable( sources, dependencies: [ config_dep, + fwupd, gio_dep, glib_dep, granite_dep, From 72a4752c08175454e93ba3c7b1c7870e66bcf9af Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Wed, 12 Jan 2022 19:08:00 +0100 Subject: [PATCH 02/14] GitHub CI: Add fwupd as dependency --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 985b0dbc..a9ce23e0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ jobs: - name: Install Dependencies run: | apt update - apt install -y libaccountsservice-dev libdbus-1-dev libgranite-dev libgeoclue-2-dev meson valac + apt install -y libaccountsservice-dev libdbus-1-dev libgranite-dev libgeoclue-2-dev libfwupd-dev meson valac - name: Build env: DESTDIR: out From 32ccd33b11782ce986fea87b3cc220c5b49fa73b Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Wed, 12 Jan 2022 20:05:57 +0100 Subject: [PATCH 03/14] Add sources --- .../io.elementary.settings-daemon.gschema.xml | 8 ++ meson.build | 6 + po/POTFILES | 1 + src/Application.vala | 18 +++ src/AsyncMutex.vala | 55 +++++++++ src/Backends/Firmware.vala | 112 ++++++++++++++++++ src/FirmwareClient.vala | 71 +++++++++++ src/meson.build | 3 + 8 files changed, 274 insertions(+) create mode 100644 src/AsyncMutex.vala create mode 100644 src/Backends/Firmware.vala create mode 100644 src/FirmwareClient.vala diff --git a/data/io.elementary.settings-daemon.gschema.xml b/data/io.elementary.settings-daemon.gschema.xml index 9d7b9457..0841032d 100644 --- a/data/io.elementary.settings-daemon.gschema.xml +++ b/data/io.elementary.settings-daemon.gschema.xml @@ -65,4 +65,12 @@ The day for calendars to use as the first day of the week + + + + 0 + Unix UTC time of last cache refresh + Used to determine when settings daemon last refreshed its caches and checked for firmware updates + + diff --git a/meson.build b/meson.build index 6331386c..416959d8 100644 --- a/meson.build +++ b/meson.build @@ -9,6 +9,12 @@ gio_dep = dependency ('gio-2.0') glib_dep = dependency('glib-2.0') granite_dep = dependency('granite', version: '>= 5.3.0') i18n = import('i18n') +gettext_name = meson.project_name() + +add_project_arguments( + '-DGETTEXT_PACKAGE="@0@"'.format(gettext_name), + language:'c' +) cc = meson.get_compiler('c') m_dep = cc.find_library('m', required : false) diff --git a/po/POTFILES b/po/POTFILES index 31a08460..5e736be4 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -1 +1,2 @@ data/settings-daemon.appdata.xml.in +src/Backends/Firmware.vala diff --git a/src/Application.vala b/src/Application.vala index 39c8a5e1..f238594f 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -42,12 +42,30 @@ public class SettingsDaemon.Application : GLib.Application { private Backends.Housekeeping housekeeping; + private Backends.Firmware firmware; + construct { application_id = Build.PROJECT_NAME; add_main_option_entries (OPTIONS); housekeeping = new Backends.Housekeeping (); + + firmware = new Backends.Firmware (this); + + var show_firmware_updates_action = new SimpleAction ("show-firmware-updates", null); + show_firmware_updates_action.activate.connect (() => { + var uri = "settings://about/firmware"; + AppInfo.launch_default_for_uri_async.begin (uri, null, null, (obj, res) => { + try { + AppInfo.launch_default_for_uri_async.end (res); + } catch (Error e) { + critical (e.message); + } + }); + }); + + add_action (show_firmware_updates_action); } public override int handle_local_options (VariantDict options) { diff --git a/src/AsyncMutex.vala b/src/AsyncMutex.vala new file mode 100644 index 00000000..816324b9 --- /dev/null +++ b/src/AsyncMutex.vala @@ -0,0 +1,55 @@ +/* +* Copyright 2019 elementary, Inc. (https://elementary.io) +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public +* License as published by the Free Software Foundation; either +* version 3 of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public +* License along with this program; if not, write to the +* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +* Boston, MA 02110-1301 USA +* +*/ + +public class AsyncMutex { + private class Callback { + public SourceFunc callback; + + public Callback (owned SourceFunc cb) { + callback = (owned)cb; + } + } + + private Gee.ArrayQueue callbacks; + private bool locked; + + public AsyncMutex () { + locked = false; + callbacks = new Gee.ArrayQueue (); + } + + public async void lock () { + while (locked) { + SourceFunc cb = lock.callback; + callbacks.offer_head (new Callback ((owned)cb)); + yield; + } + + locked = true; + } + + public void unlock () { + locked = false; + var callback = callbacks.poll_head (); + if (callback != null) { + Idle.add ((owned)callback.callback); + } + } +} diff --git a/src/Backends/Firmware.vala b/src/Backends/Firmware.vala new file mode 100644 index 00000000..48d64857 --- /dev/null +++ b/src/Backends/Firmware.vala @@ -0,0 +1,112 @@ +/* + * Copyright 2022 elementary, Inc. (https://elementary.io) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + */ + +public class SettingsDaemon.Backends.Firmware : GLib.Object { + private GLib.Settings firmware_settings; + + private GLib.DateTime last_firmware_check = null; + + private const int SECONDS_BETWEEN_REFRESHES = 60 * 60 * 24; + + public uint firmware_updates_number { get; private set; default = 0U; } + + private AsyncMutex update_notification_mutex = new AsyncMutex (); + private AsyncMutex firmware_update_notification_mutex = new AsyncMutex (); + + public GLib.Application application { get; construct; } + + public Firmware (GLib.Application application) { + Object ( + application: application + ); + } + + construct { + firmware_settings = new GLib.Settings ("io.elementary.settings-daemon.firmware"); + + last_firmware_check = new DateTime.from_unix_utc (firmware_settings.get_int64 ("last-refresh-time")); + + check_seconds_between_refreshes (); + + Timeout.add_seconds (SECONDS_BETWEEN_REFRESHES, check_seconds_between_refreshes); + } + + private bool check_seconds_between_refreshes () { + /* One cache update a day, keeps the doctor away! */ + var seconds_since_last_refresh = new DateTime.now_utc ().difference (last_firmware_check) / GLib.TimeSpan.SECOND; + if (seconds_since_last_refresh >= SECONDS_BETWEEN_REFRESHES) { + last_firmware_check = new DateTime.now_utc (); + firmware_settings.set_int64 ("last-refresh-time", last_firmware_check.to_unix ()); + + refresh_firmware_updates.begin (); + } + + return Source.CONTINUE; + } + + private async void refresh_firmware_updates () { + yield firmware_update_notification_mutex.lock (); + + bool was_empty = firmware_updates_number == 0U; + + var fwupd_client = new Fwupd.Client (); + var num_updates = 0; + try { + var devices = yield FirmwareClient.get_devices (fwupd_client); + for (int i = 0; i < devices.length; i++) { + var device = devices[i]; + if (device.has_flag (Fwupd.DEVICE_FLAG_UPDATABLE)) { + Fwupd.Release? release = null; + try { + var upgrades = yield FirmwareClient.get_upgrades (fwupd_client, device.get_id ()); + + if (upgrades != null) { + release = upgrades[0]; + } + } catch (Error e) { + warning (e.message); + } + + if (release != null && device.get_version () != release.get_version ()) { + num_updates++; + } + } + } + } catch (Error e) { + warning (e.message); + } + + if (was_empty && num_updates != 0U) { + string title = ngettext ("Firmware Update Available", "Firmware Updates Available", num_updates); + string body = ngettext ("%u update is available for your hardware", "%u updates are available for your hardware", num_updates).printf (num_updates); + + var notification = new Notification (title); + notification.set_body (body); + notification.set_icon (new ThemedIcon ("application-x-firmware")); + notification.set_default_action ("app.show-firmware-updates"); + + application.send_notification ("io.elementary.settings-daemon.firmware.updates", notification); + } else { + application.withdraw_notification ("io.elementary.settings-daemon.firmware.updates"); + } + + update_notification_mutex.unlock (); + } +} diff --git a/src/FirmwareClient.vala b/src/FirmwareClient.vala new file mode 100644 index 00000000..04689bdf --- /dev/null +++ b/src/FirmwareClient.vala @@ -0,0 +1,71 @@ +/* +* Copyright 2021 elementary, Inc. (https://elementary.io) +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public +* License as published by the Free Software Foundation; either +* version 3 of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public +* License along with this program; if not, write to the +* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +* Boston, MA 02110-1301 USA +*/ + +/* +* This class only exists to provide async methods that aren't present in older +* versions of LibFwupd. It should be removed when LibFwupd is updated. +*/ + +public class FirmwareClient { + public static async GLib.GenericArray get_devices (Fwupd.Client client) throws GLib.Error { + SourceFunc callback = get_devices.callback; + GLib.Error error = null; + + var devices = new GLib.GenericArray (); + new Thread ("get_devices", () => { + try { + devices = client.get_devices (); + } catch (Error e) { + error = e; + } + Idle.add ((owned) callback); + }); + + yield; + + if (error != null) { + throw error; + } + + return devices; + } + + public static async GLib.GenericArray get_upgrades (Fwupd.Client client, string device_id) throws GLib.Error { + SourceFunc callback = get_upgrades.callback; + GLib.Error error = null; + + var releases = new GLib.GenericArray (); + new Thread ("get_upgrades", () => { + try { + releases = client.get_upgrades (device_id); + } catch (Error e) { + error = e; + } + Idle.add ((owned) callback); + }); + + yield; + + if (error != null) { + throw error; + } + + return releases; + } +} diff --git a/src/meson.build b/src/meson.build index 94aca829..285789dd 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,7 +1,10 @@ sources = files( 'AccountsService.vala', 'Application.vala', + 'AsyncMutex.vala', + 'FirmwareClient.vala', 'SessionManager.vala', + 'Backends/Firmware.vala', 'Backends/Housekeeping.vala', 'Backends/KeyboardSettings.vala', 'Backends/MouseSettings.vala', From 5f2894f1ed0d9f9721dcd847693b809ca23e76b3 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Wed, 12 Jan 2022 21:28:58 +0100 Subject: [PATCH 04/14] Set icon --- data/autostart.desktop | 1 + 1 file changed, 1 insertion(+) diff --git a/data/autostart.desktop b/data/autostart.desktop index 0d8633fa..a5acbea3 100644 --- a/data/autostart.desktop +++ b/data/autostart.desktop @@ -3,6 +3,7 @@ Type=Application Name=Elementary Settings Daemon Comment=Elementary Settings Daemon Exec=io.elementary.settings-daemon +Icon=preferences-desktop Terminal=false Categories=System;Core; NoDisplay=true From a4de972a49ff49ad79d5fbe0ec01aa2e60a62d1a Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Thu, 13 Jan 2022 16:08:08 +0100 Subject: [PATCH 05/14] Backends/Firmware: Fix deadlock --- src/Backends/Firmware.vala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Backends/Firmware.vala b/src/Backends/Firmware.vala index 48d64857..558d3e46 100644 --- a/src/Backends/Firmware.vala +++ b/src/Backends/Firmware.vala @@ -28,7 +28,6 @@ public class SettingsDaemon.Backends.Firmware : GLib.Object { public uint firmware_updates_number { get; private set; default = 0U; } private AsyncMutex update_notification_mutex = new AsyncMutex (); - private AsyncMutex firmware_update_notification_mutex = new AsyncMutex (); public GLib.Application application { get; construct; } @@ -62,7 +61,7 @@ public class SettingsDaemon.Backends.Firmware : GLib.Object { } private async void refresh_firmware_updates () { - yield firmware_update_notification_mutex.lock (); + yield update_notification_mutex.lock (); bool was_empty = firmware_updates_number == 0U; From b762a30cb427be22d14c4e79a53837cf682a9d30 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Tue, 25 Jan 2022 16:18:23 +0100 Subject: [PATCH 06/14] Update src/Application.vala MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Danielle Foré --- src/Application.vala | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index f238594f..82fdf8af 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -55,14 +55,11 @@ public class SettingsDaemon.Application : GLib.Application { var show_firmware_updates_action = new SimpleAction ("show-firmware-updates", null); show_firmware_updates_action.activate.connect (() => { - var uri = "settings://about/firmware"; - AppInfo.launch_default_for_uri_async.begin (uri, null, null, (obj, res) => { - try { - AppInfo.launch_default_for_uri_async.end (res); - } catch (Error e) { - critical (e.message); - } - }); + try { + Gtk.show_uri_on_window (null, "settings://about/firmware", Gdk.CURRENT_TIME); + } catch (Error e) { + critical (e.message); + } }); add_action (show_firmware_updates_action); From 4974e7adefc5431358b82a4b23838406db36febc Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Sun, 6 Feb 2022 08:29:52 +0100 Subject: [PATCH 07/14] Try to use systemd timer --- .../io.elementary.settings-daemon.gschema.xml | 8 -- meson.build | 2 + .../Application.vala | 79 +++++++++++++ ...-daemon.check-for-firmware-updates.service | 8 ++ ...gs-daemon.check-for-firmware-updates.timer | 10 ++ .../check-for-firmware-updates/meson.build | 26 ++++ periodic-tasks/meson.build | 4 + src/Application.vala | 4 - src/AsyncMutex.vala | 55 --------- src/Backends/Firmware.vala | 111 ------------------ src/FirmwareClient.vala | 71 ----------- src/meson.build | 4 - 12 files changed, 129 insertions(+), 253 deletions(-) create mode 100644 periodic-tasks/check-for-firmware-updates/Application.vala create mode 100644 periodic-tasks/check-for-firmware-updates/io.elementary.settings-daemon.check-for-firmware-updates.service create mode 100644 periodic-tasks/check-for-firmware-updates/io.elementary.settings-daemon.check-for-firmware-updates.timer create mode 100644 periodic-tasks/check-for-firmware-updates/meson.build create mode 100644 periodic-tasks/meson.build delete mode 100644 src/AsyncMutex.vala delete mode 100644 src/Backends/Firmware.vala delete mode 100644 src/FirmwareClient.vala diff --git a/data/io.elementary.settings-daemon.gschema.xml b/data/io.elementary.settings-daemon.gschema.xml index 0841032d..9d7b9457 100644 --- a/data/io.elementary.settings-daemon.gschema.xml +++ b/data/io.elementary.settings-daemon.gschema.xml @@ -65,12 +65,4 @@ The day for calendars to use as the first day of the week - - - - 0 - Unix UTC time of last cache refresh - Used to determine when settings daemon last refreshed its caches and checked for firmware updates - - diff --git a/meson.build b/meson.build index 416959d8..aa0480ca 100644 --- a/meson.build +++ b/meson.build @@ -37,6 +37,7 @@ config_dep = declare_dependency( prefix = get_option('prefix') datadir = join_paths(prefix, get_option('datadir')) +libexecdir = join_paths(prefix, get_option('libexecdir')) symlink = join_paths(meson.current_source_dir (), 'meson', 'create-symlink.sh') @@ -44,5 +45,6 @@ subdir('data') subdir('po') subdir('src') subdir('settings-portal') +subdir('periodic-tasks') meson.add_install_script('meson/post_install.py') diff --git a/periodic-tasks/check-for-firmware-updates/Application.vala b/periodic-tasks/check-for-firmware-updates/Application.vala new file mode 100644 index 00000000..104f7708 --- /dev/null +++ b/periodic-tasks/check-for-firmware-updates/Application.vala @@ -0,0 +1,79 @@ +/* +* Copyright 2022 elementary, Inc. (https://elementary.io) +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public +* License as published by the Free Software Foundation; either +* version 3 of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public +* License along with this program; if not, write to the +* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +* Boston, MA 02110-1301 USA +* +*/ + +public class CheckForFirmwareUpdates.Application : GLib.Application { + private Application () {} + + public uint firmware_updates_number { get; private set; default = 0U; } + + construct { + application_id = Build.PROJECT_NAME + ".check-for-firmware-updates"; + } + + public override void activate () { + bool was_empty = firmware_updates_number == 0U; + + var fwupd_client = new Fwupd.Client (); + var num_updates = 0; + try { + var devices = fwupd_client.get_devices (); + for (int i = 0; i < devices.length; i++) { + var device = devices[i]; + if (device.has_flag (Fwupd.DEVICE_FLAG_UPDATABLE)) { + Fwupd.Release? release = null; + try { + var upgrades = fwupd_client.get_upgrades (device.get_id ()); + + if (upgrades != null) { + release = upgrades[0]; + } + } catch (Error e) { + warning (e.message); + } + + if (release != null && device.get_version () != release.get_version ()) { + num_updates++; + } + } + } + } catch (Error e) { + warning (e.message); + } + + if (was_empty && num_updates != 0U) { + string title = ngettext ("Firmware Update Available", "Firmware Updates Available", num_updates); + string body = ngettext ("%u update is available for your hardware", "%u updates are available for your hardware", num_updates).printf (num_updates); + + var notification = new Notification (title); + notification.set_body (body); + notification.set_icon (new ThemedIcon ("application-x-firmware")); + notification.set_default_action ("io.elementary.settings-daemon.show-firmware-updates"); + + send_notification ("io.elementary.settings-daemon.firmware.updates", notification); + } else { + withdraw_notification ("io.elementary.settings-daemon.firmware.updates"); + } + } + + public static int main (string[] args) { + var application = new Application (); + return application.run (args); + } +} diff --git a/periodic-tasks/check-for-firmware-updates/io.elementary.settings-daemon.check-for-firmware-updates.service b/periodic-tasks/check-for-firmware-updates/io.elementary.settings-daemon.check-for-firmware-updates.service new file mode 100644 index 00000000..de86d8ed --- /dev/null +++ b/periodic-tasks/check-for-firmware-updates/io.elementary.settings-daemon.check-for-firmware-updates.service @@ -0,0 +1,8 @@ +[Unit] +Description=Check for firmware updates daily +ConditionACPower=true +After=network.target network-online.target systemd-networkd.service NetworkManager.service connman.service + +[Service] +Type=oneshot +ExecStart=/usr/libexec/io.elementary.settings-daemon.check-for-firmware-updates diff --git a/periodic-tasks/check-for-firmware-updates/io.elementary.settings-daemon.check-for-firmware-updates.timer b/periodic-tasks/check-for-firmware-updates/io.elementary.settings-daemon.check-for-firmware-updates.timer new file mode 100644 index 00000000..04a2d8bd --- /dev/null +++ b/periodic-tasks/check-for-firmware-updates/io.elementary.settings-daemon.check-for-firmware-updates.timer @@ -0,0 +1,10 @@ + +[Unit] +Description=Check for firmware updates daily + +[Timer] +OnCalendar=daily +Persistent=true + +[Install] +WantedBy=timers.target diff --git a/periodic-tasks/check-for-firmware-updates/meson.build b/periodic-tasks/check-for-firmware-updates/meson.build new file mode 100644 index 00000000..c64743e4 --- /dev/null +++ b/periodic-tasks/check-for-firmware-updates/meson.build @@ -0,0 +1,26 @@ +sources = files( + 'Application.vala', +) + +executable( + meson.project_name() + '.check-for-firmware-updates', + sources, + dependencies: [ + config_dep, + fwupd, + gio_dep, + glib_dep, + ], + install: true, + install_dir: libexecdir, +) + +install_data( + meson.project_name() + '.check-for-firmware-updates.service', + install_dir: systemd_system_unit_dir +) + +install_data( + meson.project_name() + '.check-for-firmware-updates.timer', + install_dir: systemd_system_unit_dir +) diff --git a/periodic-tasks/meson.build b/periodic-tasks/meson.build new file mode 100644 index 00000000..3ec525db --- /dev/null +++ b/periodic-tasks/meson.build @@ -0,0 +1,4 @@ +systemd = dependency('systemd') +systemd_system_unit_dir = systemd.get_pkgconfig_variable('systemdsystemunitdir') + +subdir('check-for-firmware-updates') diff --git a/src/Application.vala b/src/Application.vala index 82fdf8af..3b94b5e1 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -42,8 +42,6 @@ public class SettingsDaemon.Application : GLib.Application { private Backends.Housekeeping housekeeping; - private Backends.Firmware firmware; - construct { application_id = Build.PROJECT_NAME; @@ -51,8 +49,6 @@ public class SettingsDaemon.Application : GLib.Application { housekeeping = new Backends.Housekeeping (); - firmware = new Backends.Firmware (this); - var show_firmware_updates_action = new SimpleAction ("show-firmware-updates", null); show_firmware_updates_action.activate.connect (() => { try { diff --git a/src/AsyncMutex.vala b/src/AsyncMutex.vala deleted file mode 100644 index 816324b9..00000000 --- a/src/AsyncMutex.vala +++ /dev/null @@ -1,55 +0,0 @@ -/* -* Copyright 2019 elementary, Inc. (https://elementary.io) -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public -* License as published by the Free Software Foundation; either -* version 3 of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public -* License along with this program; if not, write to the -* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -* Boston, MA 02110-1301 USA -* -*/ - -public class AsyncMutex { - private class Callback { - public SourceFunc callback; - - public Callback (owned SourceFunc cb) { - callback = (owned)cb; - } - } - - private Gee.ArrayQueue callbacks; - private bool locked; - - public AsyncMutex () { - locked = false; - callbacks = new Gee.ArrayQueue (); - } - - public async void lock () { - while (locked) { - SourceFunc cb = lock.callback; - callbacks.offer_head (new Callback ((owned)cb)); - yield; - } - - locked = true; - } - - public void unlock () { - locked = false; - var callback = callbacks.poll_head (); - if (callback != null) { - Idle.add ((owned)callback.callback); - } - } -} diff --git a/src/Backends/Firmware.vala b/src/Backends/Firmware.vala deleted file mode 100644 index 558d3e46..00000000 --- a/src/Backends/Firmware.vala +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2022 elementary, Inc. (https://elementary.io) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301 USA - * - */ - -public class SettingsDaemon.Backends.Firmware : GLib.Object { - private GLib.Settings firmware_settings; - - private GLib.DateTime last_firmware_check = null; - - private const int SECONDS_BETWEEN_REFRESHES = 60 * 60 * 24; - - public uint firmware_updates_number { get; private set; default = 0U; } - - private AsyncMutex update_notification_mutex = new AsyncMutex (); - - public GLib.Application application { get; construct; } - - public Firmware (GLib.Application application) { - Object ( - application: application - ); - } - - construct { - firmware_settings = new GLib.Settings ("io.elementary.settings-daemon.firmware"); - - last_firmware_check = new DateTime.from_unix_utc (firmware_settings.get_int64 ("last-refresh-time")); - - check_seconds_between_refreshes (); - - Timeout.add_seconds (SECONDS_BETWEEN_REFRESHES, check_seconds_between_refreshes); - } - - private bool check_seconds_between_refreshes () { - /* One cache update a day, keeps the doctor away! */ - var seconds_since_last_refresh = new DateTime.now_utc ().difference (last_firmware_check) / GLib.TimeSpan.SECOND; - if (seconds_since_last_refresh >= SECONDS_BETWEEN_REFRESHES) { - last_firmware_check = new DateTime.now_utc (); - firmware_settings.set_int64 ("last-refresh-time", last_firmware_check.to_unix ()); - - refresh_firmware_updates.begin (); - } - - return Source.CONTINUE; - } - - private async void refresh_firmware_updates () { - yield update_notification_mutex.lock (); - - bool was_empty = firmware_updates_number == 0U; - - var fwupd_client = new Fwupd.Client (); - var num_updates = 0; - try { - var devices = yield FirmwareClient.get_devices (fwupd_client); - for (int i = 0; i < devices.length; i++) { - var device = devices[i]; - if (device.has_flag (Fwupd.DEVICE_FLAG_UPDATABLE)) { - Fwupd.Release? release = null; - try { - var upgrades = yield FirmwareClient.get_upgrades (fwupd_client, device.get_id ()); - - if (upgrades != null) { - release = upgrades[0]; - } - } catch (Error e) { - warning (e.message); - } - - if (release != null && device.get_version () != release.get_version ()) { - num_updates++; - } - } - } - } catch (Error e) { - warning (e.message); - } - - if (was_empty && num_updates != 0U) { - string title = ngettext ("Firmware Update Available", "Firmware Updates Available", num_updates); - string body = ngettext ("%u update is available for your hardware", "%u updates are available for your hardware", num_updates).printf (num_updates); - - var notification = new Notification (title); - notification.set_body (body); - notification.set_icon (new ThemedIcon ("application-x-firmware")); - notification.set_default_action ("app.show-firmware-updates"); - - application.send_notification ("io.elementary.settings-daemon.firmware.updates", notification); - } else { - application.withdraw_notification ("io.elementary.settings-daemon.firmware.updates"); - } - - update_notification_mutex.unlock (); - } -} diff --git a/src/FirmwareClient.vala b/src/FirmwareClient.vala deleted file mode 100644 index 04689bdf..00000000 --- a/src/FirmwareClient.vala +++ /dev/null @@ -1,71 +0,0 @@ -/* -* Copyright 2021 elementary, Inc. (https://elementary.io) -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public -* License as published by the Free Software Foundation; either -* version 3 of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public -* License along with this program; if not, write to the -* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -* Boston, MA 02110-1301 USA -*/ - -/* -* This class only exists to provide async methods that aren't present in older -* versions of LibFwupd. It should be removed when LibFwupd is updated. -*/ - -public class FirmwareClient { - public static async GLib.GenericArray get_devices (Fwupd.Client client) throws GLib.Error { - SourceFunc callback = get_devices.callback; - GLib.Error error = null; - - var devices = new GLib.GenericArray (); - new Thread ("get_devices", () => { - try { - devices = client.get_devices (); - } catch (Error e) { - error = e; - } - Idle.add ((owned) callback); - }); - - yield; - - if (error != null) { - throw error; - } - - return devices; - } - - public static async GLib.GenericArray get_upgrades (Fwupd.Client client, string device_id) throws GLib.Error { - SourceFunc callback = get_upgrades.callback; - GLib.Error error = null; - - var releases = new GLib.GenericArray (); - new Thread ("get_upgrades", () => { - try { - releases = client.get_upgrades (device_id); - } catch (Error e) { - error = e; - } - Idle.add ((owned) callback); - }); - - yield; - - if (error != null) { - throw error; - } - - return releases; - } -} diff --git a/src/meson.build b/src/meson.build index 285789dd..7c726d97 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,10 +1,7 @@ sources = files( 'AccountsService.vala', 'Application.vala', - 'AsyncMutex.vala', - 'FirmwareClient.vala', 'SessionManager.vala', - 'Backends/Firmware.vala', 'Backends/Housekeeping.vala', 'Backends/KeyboardSettings.vala', 'Backends/MouseSettings.vala', @@ -17,7 +14,6 @@ executable( sources, dependencies: [ config_dep, - fwupd, gio_dep, glib_dep, granite_dep, From 3f3488f65206c9379daf1254d4c262764030ad26 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Mon, 7 Nov 2022 22:37:37 +0100 Subject: [PATCH 08/14] Remove whitespace --- ...o.elementary.settings-daemon.check-for-firmware-updates.timer | 1 - 1 file changed, 1 deletion(-) diff --git a/periodic-tasks/check-for-firmware-updates/io.elementary.settings-daemon.check-for-firmware-updates.timer b/periodic-tasks/check-for-firmware-updates/io.elementary.settings-daemon.check-for-firmware-updates.timer index 04a2d8bd..43ed38aa 100644 --- a/periodic-tasks/check-for-firmware-updates/io.elementary.settings-daemon.check-for-firmware-updates.timer +++ b/periodic-tasks/check-for-firmware-updates/io.elementary.settings-daemon.check-for-firmware-updates.timer @@ -1,4 +1,3 @@ - [Unit] Description=Check for firmware updates daily From 56f263b7ada77cde9e4f2d28f918a9d1fc5b0019 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Sat, 24 Dec 2022 06:11:26 +0100 Subject: [PATCH 09/14] Refactor --- periodic-tasks/check-for-firmware-updates/Application.vala | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/periodic-tasks/check-for-firmware-updates/Application.vala b/periodic-tasks/check-for-firmware-updates/Application.vala index 104f7708..0e54e217 100644 --- a/periodic-tasks/check-for-firmware-updates/Application.vala +++ b/periodic-tasks/check-for-firmware-updates/Application.vala @@ -28,8 +28,6 @@ public class CheckForFirmwareUpdates.Application : GLib.Application { } public override void activate () { - bool was_empty = firmware_updates_number == 0U; - var fwupd_client = new Fwupd.Client (); var num_updates = 0; try { @@ -57,7 +55,7 @@ public class CheckForFirmwareUpdates.Application : GLib.Application { warning (e.message); } - if (was_empty && num_updates != 0U) { + if (firmware_updates_number == 0U && num_updates != 0U) { string title = ngettext ("Firmware Update Available", "Firmware Updates Available", num_updates); string body = ngettext ("%u update is available for your hardware", "%u updates are available for your hardware", num_updates).printf (num_updates); From 3820951f8175f1a811cd643b17f00fd6d9366700 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Tue, 27 Dec 2022 13:32:11 +0100 Subject: [PATCH 10/14] Use busctl to trigger firmware check periodically --- ...-daemon.check-for-firmware-updates.service | 2 +- ...gs-daemon.check-for-firmware-updates.timer | 0 data/meson.build | 13 ++++ meson.build | 4 +- .../Application.vala | 77 ------------------- .../check-for-firmware-updates/meson.build | 26 ------- periodic-tasks/meson.build | 4 - po/POTFILES | 2 +- src/Application.vala | 47 +++++++++++ src/meson.build | 1 + 10 files changed, 64 insertions(+), 112 deletions(-) rename {periodic-tasks/check-for-firmware-updates => data}/io.elementary.settings-daemon.check-for-firmware-updates.service (53%) rename {periodic-tasks/check-for-firmware-updates => data}/io.elementary.settings-daemon.check-for-firmware-updates.timer (100%) delete mode 100644 periodic-tasks/check-for-firmware-updates/Application.vala delete mode 100644 periodic-tasks/check-for-firmware-updates/meson.build delete mode 100644 periodic-tasks/meson.build diff --git a/periodic-tasks/check-for-firmware-updates/io.elementary.settings-daemon.check-for-firmware-updates.service b/data/io.elementary.settings-daemon.check-for-firmware-updates.service similarity index 53% rename from periodic-tasks/check-for-firmware-updates/io.elementary.settings-daemon.check-for-firmware-updates.service rename to data/io.elementary.settings-daemon.check-for-firmware-updates.service index de86d8ed..5f79b95e 100644 --- a/periodic-tasks/check-for-firmware-updates/io.elementary.settings-daemon.check-for-firmware-updates.service +++ b/data/io.elementary.settings-daemon.check-for-firmware-updates.service @@ -5,4 +5,4 @@ After=network.target network-online.target systemd-networkd.service NetworkManag [Service] Type=oneshot -ExecStart=/usr/libexec/io.elementary.settings-daemon.check-for-firmware-updates +ExecStart=/usr/bin/busctl --user call io.elementary.settings-daemon /io/elementary/settings_daemon org.freedesktop.Application ActivateAction sava{sv} "check-firmware-updates" 0 0 diff --git a/periodic-tasks/check-for-firmware-updates/io.elementary.settings-daemon.check-for-firmware-updates.timer b/data/io.elementary.settings-daemon.check-for-firmware-updates.timer similarity index 100% rename from periodic-tasks/check-for-firmware-updates/io.elementary.settings-daemon.check-for-firmware-updates.timer rename to data/io.elementary.settings-daemon.check-for-firmware-updates.timer diff --git a/data/meson.build b/data/meson.build index 4db0d403..c64c2dcc 100644 --- a/data/meson.build +++ b/data/meson.build @@ -34,3 +34,16 @@ i18n.merge_file( install: true, install_dir: join_paths(get_option('datadir'), 'metainfo'), ) + +systemd = dependency('systemd') +systemd_system_unit_dir = systemd.get_pkgconfig_variable('systemdsystemunitdir') + +install_data( + meson.project_name() + '.check-for-firmware-updates.service', + install_dir: systemd_system_unit_dir +) + +install_data( + meson.project_name() + '.check-for-firmware-updates.timer', + install_dir: systemd_system_unit_dir +) diff --git a/meson.build b/meson.build index facc5627..99b937ac 100644 --- a/meson.build +++ b/meson.build @@ -4,7 +4,7 @@ project('io.elementary.settings-daemon', license: 'GPL3', ) -fwupd = dependency('fwupd') +fwupd_dep = dependency('fwupd') gio_dep = dependency ('gio-2.0') glib_dep = dependency('glib-2.0') granite_dep = dependency('granite', version: '>= 5.3.0') @@ -37,7 +37,6 @@ config_dep = declare_dependency( prefix = get_option('prefix') datadir = join_paths(prefix, get_option('datadir')) -libexecdir = join_paths(prefix, get_option('libexecdir')) symlink = join_paths(meson.current_source_dir (), 'meson', 'create-symlink.sh') @@ -45,6 +44,5 @@ subdir('data') subdir('po') subdir('src') subdir('settings-portal') -subdir('periodic-tasks') meson.add_install_script('meson/post_install.py') diff --git a/periodic-tasks/check-for-firmware-updates/Application.vala b/periodic-tasks/check-for-firmware-updates/Application.vala deleted file mode 100644 index 0e54e217..00000000 --- a/periodic-tasks/check-for-firmware-updates/Application.vala +++ /dev/null @@ -1,77 +0,0 @@ -/* -* Copyright 2022 elementary, Inc. (https://elementary.io) -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public -* License as published by the Free Software Foundation; either -* version 3 of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public -* License along with this program; if not, write to the -* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, -* Boston, MA 02110-1301 USA -* -*/ - -public class CheckForFirmwareUpdates.Application : GLib.Application { - private Application () {} - - public uint firmware_updates_number { get; private set; default = 0U; } - - construct { - application_id = Build.PROJECT_NAME + ".check-for-firmware-updates"; - } - - public override void activate () { - var fwupd_client = new Fwupd.Client (); - var num_updates = 0; - try { - var devices = fwupd_client.get_devices (); - for (int i = 0; i < devices.length; i++) { - var device = devices[i]; - if (device.has_flag (Fwupd.DEVICE_FLAG_UPDATABLE)) { - Fwupd.Release? release = null; - try { - var upgrades = fwupd_client.get_upgrades (device.get_id ()); - - if (upgrades != null) { - release = upgrades[0]; - } - } catch (Error e) { - warning (e.message); - } - - if (release != null && device.get_version () != release.get_version ()) { - num_updates++; - } - } - } - } catch (Error e) { - warning (e.message); - } - - if (firmware_updates_number == 0U && num_updates != 0U) { - string title = ngettext ("Firmware Update Available", "Firmware Updates Available", num_updates); - string body = ngettext ("%u update is available for your hardware", "%u updates are available for your hardware", num_updates).printf (num_updates); - - var notification = new Notification (title); - notification.set_body (body); - notification.set_icon (new ThemedIcon ("application-x-firmware")); - notification.set_default_action ("io.elementary.settings-daemon.show-firmware-updates"); - - send_notification ("io.elementary.settings-daemon.firmware.updates", notification); - } else { - withdraw_notification ("io.elementary.settings-daemon.firmware.updates"); - } - } - - public static int main (string[] args) { - var application = new Application (); - return application.run (args); - } -} diff --git a/periodic-tasks/check-for-firmware-updates/meson.build b/periodic-tasks/check-for-firmware-updates/meson.build deleted file mode 100644 index c64743e4..00000000 --- a/periodic-tasks/check-for-firmware-updates/meson.build +++ /dev/null @@ -1,26 +0,0 @@ -sources = files( - 'Application.vala', -) - -executable( - meson.project_name() + '.check-for-firmware-updates', - sources, - dependencies: [ - config_dep, - fwupd, - gio_dep, - glib_dep, - ], - install: true, - install_dir: libexecdir, -) - -install_data( - meson.project_name() + '.check-for-firmware-updates.service', - install_dir: systemd_system_unit_dir -) - -install_data( - meson.project_name() + '.check-for-firmware-updates.timer', - install_dir: systemd_system_unit_dir -) diff --git a/periodic-tasks/meson.build b/periodic-tasks/meson.build deleted file mode 100644 index 3ec525db..00000000 --- a/periodic-tasks/meson.build +++ /dev/null @@ -1,4 +0,0 @@ -systemd = dependency('systemd') -systemd_system_unit_dir = systemd.get_pkgconfig_variable('systemdsystemunitdir') - -subdir('check-for-firmware-updates') diff --git a/po/POTFILES b/po/POTFILES index 5e736be4..469c9356 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -1,2 +1,2 @@ data/settings-daemon.appdata.xml.in -src/Backends/Firmware.vala +src/Application.vala diff --git a/src/Application.vala b/src/Application.vala index 3b94b5e1..427ee833 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -42,6 +42,8 @@ public class SettingsDaemon.Application : GLib.Application { private Backends.Housekeeping housekeeping; + public uint firmware_updates_number { get; private set; default = 0U; } + construct { application_id = Build.PROJECT_NAME; @@ -49,6 +51,50 @@ public class SettingsDaemon.Application : GLib.Application { housekeeping = new Backends.Housekeeping (); + var check_firmware_updates_action = new SimpleAction ("check-firmware-updates", null); + check_firmware_updates_action.activate.connect (() => { + var fwupd_client = new Fwupd.Client (); + var num_updates = 0; + try { + var devices = fwupd_client.get_devices (); + for (int i = 0; i < devices.length; i++) { + var device = devices[i]; + if (device.has_flag (Fwupd.DEVICE_FLAG_UPDATABLE)) { + Fwupd.Release? release = null; + try { + var upgrades = fwupd_client.get_upgrades (device.get_id ()); + + if (upgrades != null) { + release = upgrades[0]; + } + } catch (Error e) { + warning (e.message); + } + + if (release != null && device.get_version () != release.get_version ()) { + num_updates++; + } + } + } + } catch (Error e) { + warning (e.message); + } + + if (firmware_updates_number == 0U && num_updates != 0U) { + string title = ngettext ("Firmware Update Available", "Firmware Updates Available", num_updates); + string body = ngettext ("%u update is available for your hardware", "%u updates are available for your hardware", num_updates).printf (num_updates); + + var notification = new Notification (title); + notification.set_body (body); + notification.set_icon (new ThemedIcon ("application-x-firmware")); + notification.set_default_action ("io.elementary.settings-daemon.show-firmware-updates"); + + send_notification ("io.elementary.settings-daemon.firmware.updates", notification); + } else { + withdraw_notification ("io.elementary.settings-daemon.firmware.updates"); + } + }); + var show_firmware_updates_action = new SimpleAction ("show-firmware-updates", null); show_firmware_updates_action.activate.connect (() => { try { @@ -58,6 +104,7 @@ public class SettingsDaemon.Application : GLib.Application { } }); + add_action (check_firmware_updates_action); add_action (show_firmware_updates_action); } diff --git a/src/meson.build b/src/meson.build index 7c726d97..a61bb9e6 100644 --- a/src/meson.build +++ b/src/meson.build @@ -14,6 +14,7 @@ executable( sources, dependencies: [ config_dep, + fwupd_dep, gio_dep, glib_dep, granite_dep, From 54d2dd2dec57afd29dc776d78207e6bd73648ed1 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Tue, 27 Dec 2022 13:34:20 +0100 Subject: [PATCH 11/14] Application: Remove unused code --- src/Application.vala | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Application.vala b/src/Application.vala index 427ee833..c0a6392a 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -42,8 +42,6 @@ public class SettingsDaemon.Application : GLib.Application { private Backends.Housekeeping housekeeping; - public uint firmware_updates_number { get; private set; default = 0U; } - construct { application_id = Build.PROJECT_NAME; @@ -80,7 +78,7 @@ public class SettingsDaemon.Application : GLib.Application { warning (e.message); } - if (firmware_updates_number == 0U && num_updates != 0U) { + if (num_updates != 0U) { string title = ngettext ("Firmware Update Available", "Firmware Updates Available", num_updates); string body = ngettext ("%u update is available for your hardware", "%u updates are available for your hardware", num_updates).printf (num_updates); From f5817989b9282b7d0f2444fa0a95c02002b2d624 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Tue, 27 Dec 2022 14:02:58 +0100 Subject: [PATCH 12/14] Application: Fix default action name --- src/Application.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Application.vala b/src/Application.vala index c0a6392a..543db2ac 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -85,7 +85,7 @@ public class SettingsDaemon.Application : GLib.Application { var notification = new Notification (title); notification.set_body (body); notification.set_icon (new ThemedIcon ("application-x-firmware")); - notification.set_default_action ("io.elementary.settings-daemon.show-firmware-updates"); + notification.set_default_action ("app.show-firmware-updates"); send_notification ("io.elementary.settings-daemon.firmware.updates", notification); } else { From 28052b3e632a4ed1c8346a53198725aae1ba1597 Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Tue, 27 Dec 2022 14:24:58 +0100 Subject: [PATCH 13/14] Ship own icon --- data/autostart.desktop | 2 +- data/icons/128.svg | 349 ++++++++++++++++++++++++++++++ data/icons/24.svg | 297 +++++++++++++++++++++++++ data/icons/32.svg | 301 ++++++++++++++++++++++++++ data/icons/48.svg | 481 +++++++++++++++++++++++++++++++++++++++++ data/icons/64.svg | 297 +++++++++++++++++++++++++ data/meson.build | 15 ++ 7 files changed, 1741 insertions(+), 1 deletion(-) create mode 100644 data/icons/128.svg create mode 100644 data/icons/24.svg create mode 100644 data/icons/32.svg create mode 100644 data/icons/48.svg create mode 100644 data/icons/64.svg diff --git a/data/autostart.desktop b/data/autostart.desktop index a5acbea3..ef712fc7 100644 --- a/data/autostart.desktop +++ b/data/autostart.desktop @@ -3,7 +3,7 @@ Type=Application Name=Elementary Settings Daemon Comment=Elementary Settings Daemon Exec=io.elementary.settings-daemon -Icon=preferences-desktop +Icon=io.elementary.settings-daemon Terminal=false Categories=System;Core; NoDisplay=true diff --git a/data/icons/128.svg b/data/icons/128.svg new file mode 100644 index 00000000..71c5cc66 --- /dev/null +++ b/data/icons/128.svg @@ -0,0 +1,349 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/icons/24.svg b/data/icons/24.svg new file mode 100644 index 00000000..a70ef4d3 --- /dev/null +++ b/data/icons/24.svg @@ -0,0 +1,297 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/icons/32.svg b/data/icons/32.svg new file mode 100644 index 00000000..960f517a --- /dev/null +++ b/data/icons/32.svg @@ -0,0 +1,301 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/icons/48.svg b/data/icons/48.svg new file mode 100644 index 00000000..46648295 --- /dev/null +++ b/data/icons/48.svg @@ -0,0 +1,481 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/icons/64.svg b/data/icons/64.svg new file mode 100644 index 00000000..ec7989aa --- /dev/null +++ b/data/icons/64.svg @@ -0,0 +1,297 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/meson.build b/data/meson.build index c64c2dcc..dfd745a7 100644 --- a/data/meson.build +++ b/data/meson.build @@ -47,3 +47,18 @@ install_data( meson.project_name() + '.check-for-firmware-updates.timer', install_dir: systemd_system_unit_dir ) + +icon_sizes = ['24', '32', '48', '64', '128'] + +foreach i : icon_sizes + install_data( + join_paths('icons', i + '.svg'), + install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', i + 'x' + i, 'apps'), + rename: meson.project_name() + '.svg' + ) + install_data( + join_paths('icons', i + '.svg'), + install_dir: join_paths(get_option('datadir'), 'icons', 'hicolor', i + 'x' + i + '@2', 'apps'), + rename: meson.project_name() + '.svg' + ) +endforeach From c062e5a870d6ea40da0d8e3dabb75957ddf9852e Mon Sep 17 00:00:00 2001 From: Marius Meisenzahl Date: Tue, 27 Dec 2022 15:48:16 +0100 Subject: [PATCH 14/14] meson: Symlink desktop file --- data/meson.build | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/data/meson.build b/data/meson.build index dfd745a7..1c59294c 100644 --- a/data/meson.build +++ b/data/meson.build @@ -1,9 +1,15 @@ install_data( 'autostart.desktop', - install_dir: join_paths(get_option('sysconfdir'), 'xdg', 'autostart'), + install_dir: join_paths(get_option('datadir'), 'applications'), rename: meson.project_name() + '.desktop' ) +meson.add_install_script( + symlink, + join_paths(get_option('datadir'), 'applications', meson.project_name() + '.desktop'), + join_paths(get_option('sysconfdir'), 'xdg', 'autostart', meson.project_name() + '.desktop'), +) + dbus_dep = dependency('dbus-1') dbus_interfaces_dir = dbus_dep.get_pkgconfig_variable('interfaces_dir', define_variable: ['datadir', datadir])