diff --git a/data/io.elementary.settings-daemon.gschema.xml b/data/io.elementary.settings-daemon.gschema.xml index 506e381b..40a3347d 100644 --- a/data/io.elementary.settings-daemon.gschema.xml +++ b/data/io.elementary.settings-daemon.gschema.xml @@ -88,4 +88,17 @@ How often to check for updates in seconds. + + + + "balanced" + Power profile to use when plugged in + + + + "balanced" + Power profile to use on battery + + + diff --git a/po/fr.po b/po/fr.po index a247d3ae..0826550e 100644 --- a/po/fr.po +++ b/po/fr.po @@ -8,16 +8,16 @@ msgstr "" "Project-Id-Version: extra\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-01-28 22:41+0000\n" -"PO-Revision-Date: 2023-08-01 16:35+0000\n" +"PO-Revision-Date: 2024-02-08 09:11+0000\n" "Last-Translator: Nathan \n" -"Language-Team: French \n" +"Language-Team: French \n" "Language: fr\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n > 1;\n" -"X-Generator: Weblate 4.17\n" +"X-Generator: Weblate 5.0.2\n" #: data/settings-daemon.metainfo.xml.in:10 msgid "Settings Daemon" @@ -110,180 +110,169 @@ msgstr[0] "%u mise à jour est disponible pour votre matériel" msgstr[1] "%u mises à jour sont disponibles pour votre matériel" #: src/Backends/SystemUpdate.vala:124 -#, fuzzy -#| msgid "Firmware Update Available" -#| msgid_plural "Firmware Updates Available" msgid "Update available" -msgstr "Mise à jour du micrologiciel disponible" +msgstr "Mise à jour disponible" #: src/Backends/SystemUpdate.vala:128 -#, fuzzy -#| msgid "Firmware Update Available" -#| msgid_plural "Firmware Updates Available" msgid "A system security update is available" -msgstr "Mise à jour du micrologiciel disponible" +msgstr "Une mise à jour de sécurité du système est disponible" #: src/Backends/SystemUpdate.vala:132 -#, fuzzy -#| msgid "Firmware Update Available" -#| msgid_plural "Firmware Updates Available" msgid "A system update is available" -msgstr "Mise à jour du micrologiciel disponible" +msgstr "Une mise à jour du système est disponible" #: src/Backends/SystemUpdate.vala:166 msgid "Restart required" -msgstr "" +msgstr "Redémarrage nécessaire" #: src/Backends/SystemUpdate.vala:167 msgid "Please restart your system to finalize updates" -msgstr "" +msgstr "Veuillez redémarrer votre système pour terminer les mises à jour" #: src/Backends/SystemUpdate.vala:189 msgid "System updates couldn't be installed" -msgstr "" +msgstr "Les mises à jour du système n'ont pas pu être installées" #: src/Backends/SystemUpdate.vala:190 msgid "An error occurred while trying to update your system" -msgstr "" +msgstr "Une erreur s'est produite lors de la mise à jour de votre système" #: src/Backends/SystemUpdate.vala:212 msgid "Starting" -msgstr "" +msgstr "Démarrage" #: src/Backends/SystemUpdate.vala:214 msgid "Waiting" -msgstr "" +msgstr "En attente" #: src/Backends/SystemUpdate.vala:216 msgid "Running" -msgstr "" +msgstr "En cours" #: src/Backends/SystemUpdate.vala:218 msgid "Querying" -msgstr "" +msgstr "Interrogation" #: src/Backends/SystemUpdate.vala:220 msgid "Getting information" -msgstr "" +msgstr "Récupération des informations" #: src/Backends/SystemUpdate.vala:222 msgid "Removing packages" -msgstr "" +msgstr "Suppression des paquets" #: src/Backends/SystemUpdate.vala:224 msgid "Downloading" -msgstr "" +msgstr "Téléchargement" #: src/Backends/SystemUpdate.vala:226 msgid "Refreshing software list" -msgstr "" +msgstr "Mise à jour de la liste des logiciels" #: src/Backends/SystemUpdate.vala:228 msgid "Installing updates" -msgstr "" +msgstr "Installation des mises à jour" #: src/Backends/SystemUpdate.vala:230 msgid "Cleaning up packages" -msgstr "" +msgstr "Nettoyage des paquets" #: src/Backends/SystemUpdate.vala:232 msgid "Obsoleting packages" -msgstr "" +msgstr "Mise en obsolescence des paquets" #: src/Backends/SystemUpdate.vala:234 msgid "Resolving dependencies" -msgstr "" +msgstr "Résolution des dépendances" #: src/Backends/SystemUpdate.vala:236 msgid "Checking signatures" -msgstr "" +msgstr "Vérification des signatures" #: src/Backends/SystemUpdate.vala:238 msgid "Testing changes" -msgstr "" +msgstr "Vérification des modifications" #: src/Backends/SystemUpdate.vala:240 msgid "Committing changes" -msgstr "" +msgstr "Validation des modifications" #: src/Backends/SystemUpdate.vala:242 msgid "Requesting data" -msgstr "" +msgstr "Interrogation des données" #: src/Backends/SystemUpdate.vala:244 msgid "Finished" -msgstr "" +msgstr "Terminé" #: src/Backends/SystemUpdate.vala:246 msgid "Cancelling" -msgstr "" +msgstr "Annulation" #: src/Backends/SystemUpdate.vala:248 msgid "Downloading repository information" -msgstr "" +msgstr "Téléchargement des informations du dépôt" #: src/Backends/SystemUpdate.vala:250 msgid "Downloading list of packages" -msgstr "" +msgstr "Téléchargement de la liste des paquets" #: src/Backends/SystemUpdate.vala:252 msgid "Downloading file lists" -msgstr "" +msgstr "Téléchargement de la liste des fichiers" #: src/Backends/SystemUpdate.vala:254 msgid "Downloading lists of changes" -msgstr "" +msgstr "Téléchargement de la liste des modifications" #: src/Backends/SystemUpdate.vala:256 msgid "Downloading groups" -msgstr "" +msgstr "Téléchargement des groupes" #: src/Backends/SystemUpdate.vala:258 msgid "Downloading update information" -msgstr "" +msgstr "Téléchargement des informations de mise à jour" #: src/Backends/SystemUpdate.vala:260 msgid "Repackaging files" -msgstr "" +msgstr "Enpaquetage des fichiers" #: src/Backends/SystemUpdate.vala:262 msgid "Loading cache" -msgstr "" +msgstr "Chargement du cache" #: src/Backends/SystemUpdate.vala:264 msgid "Scanning applications" -msgstr "" +msgstr "Analyse des applications" #: src/Backends/SystemUpdate.vala:266 msgid "Generating package lists" -msgstr "" +msgstr "Génération de la liste des paquets" #: src/Backends/SystemUpdate.vala:268 msgid "Waiting for package manager lock" -msgstr "" +msgstr "En attente du verrou du gestionnaire de paquets" #: src/Backends/SystemUpdate.vala:270 msgid "Waiting for authentication" -msgstr "" +msgstr "En attente d'authentification" #: src/Backends/SystemUpdate.vala:272 -#, fuzzy -#| msgid "Updated translations" msgid "Updating running applications" -msgstr "Mise à jour des traductions" +msgstr "Mise à jour des applications en cours d'exécution" #: src/Backends/SystemUpdate.vala:274 msgid "Checking applications in use" -msgstr "" +msgstr "Vérification des applications en cours d'utilisation" #: src/Backends/SystemUpdate.vala:276 msgid "Checking libraries in use" -msgstr "" +msgstr "Vérification des bibliothèques en cours d'utilisation" #: src/Backends/SystemUpdate.vala:278 msgid "Copying files" -msgstr "" +msgstr "Copie des fichiers" #: src/Backends/SystemUpdate.vala:281 msgid "Installing" -msgstr "" +msgstr "Installation" diff --git a/po/ja.po b/po/ja.po index acb50921..9db21b75 100644 --- a/po/ja.po +++ b/po/ja.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: extra\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2024-01-28 22:41+0000\n" -"PO-Revision-Date: 2023-07-23 14:07+0000\n" +"PO-Revision-Date: 2024-02-12 08:12+0000\n" "Last-Translator: Ryo Nakano \n" "Language-Team: Japanese \n" @@ -17,7 +17,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=1; plural=0;\n" -"X-Generator: Weblate 4.17\n" +"X-Generator: Weblate 5.0.2\n" #: data/settings-daemon.metainfo.xml.in:10 msgid "Settings Daemon" @@ -93,7 +93,7 @@ msgstr "ダークスタイル用の GSettings スキーマが未使用のため #: data/settings-daemon.metainfo.xml.in:89 msgid "Initial release" -msgstr "最初のリリース" +msgstr "初リリース" #: src/Application.vala:160 msgid "Firmware Update Available" @@ -107,180 +107,169 @@ msgid_plural "%u updates are available for your hardware" msgstr[0] "お使いのハードウェアに%u件のアップデートが利用可能です" #: src/Backends/SystemUpdate.vala:124 -#, fuzzy -#| msgid "Firmware Update Available" -#| msgid_plural "Firmware Updates Available" msgid "Update available" -msgstr "ファームウェアアップデートが利用可能です" +msgstr "アップデートが利用可能です" #: src/Backends/SystemUpdate.vala:128 -#, fuzzy -#| msgid "Firmware Update Available" -#| msgid_plural "Firmware Updates Available" msgid "A system security update is available" -msgstr "ファームウェアアップデートが利用可能です" +msgstr "システムセキュリティアップデートが利用可能です" #: src/Backends/SystemUpdate.vala:132 -#, fuzzy -#| msgid "Firmware Update Available" -#| msgid_plural "Firmware Updates Available" msgid "A system update is available" -msgstr "ファームウェアアップデートが利用可能です" +msgstr "システムアップデートが利用可能です" #: src/Backends/SystemUpdate.vala:166 msgid "Restart required" -msgstr "" +msgstr "再起動が必要" #: src/Backends/SystemUpdate.vala:167 msgid "Please restart your system to finalize updates" -msgstr "" +msgstr "アップデートを完了するにはシステムを再起動してください" #: src/Backends/SystemUpdate.vala:189 msgid "System updates couldn't be installed" -msgstr "" +msgstr "システムアップデートをインストールできませんでした" #: src/Backends/SystemUpdate.vala:190 msgid "An error occurred while trying to update your system" -msgstr "" +msgstr "システムアップデート試行中にエラーが発生しました" #: src/Backends/SystemUpdate.vala:212 msgid "Starting" -msgstr "" +msgstr "開始しています" #: src/Backends/SystemUpdate.vala:214 msgid "Waiting" -msgstr "" +msgstr "待機しています" #: src/Backends/SystemUpdate.vala:216 msgid "Running" -msgstr "" +msgstr "実行しています" #: src/Backends/SystemUpdate.vala:218 msgid "Querying" -msgstr "" +msgstr "問い合わせています" #: src/Backends/SystemUpdate.vala:220 msgid "Getting information" -msgstr "" +msgstr "情報を取得しています" #: src/Backends/SystemUpdate.vala:222 msgid "Removing packages" -msgstr "" +msgstr "パッケージを削除しています" #: src/Backends/SystemUpdate.vala:224 msgid "Downloading" -msgstr "" +msgstr "ダウンロードしています" #: src/Backends/SystemUpdate.vala:226 msgid "Refreshing software list" -msgstr "" +msgstr "ソフトウェアの一覧を更新しています" #: src/Backends/SystemUpdate.vala:228 msgid "Installing updates" -msgstr "" +msgstr "アップデートをインストールしています" #: src/Backends/SystemUpdate.vala:230 msgid "Cleaning up packages" -msgstr "" +msgstr "パッケージをクリーンアップしています" #: src/Backends/SystemUpdate.vala:232 msgid "Obsoleting packages" -msgstr "" +msgstr "古いパッケージを取り除いています" #: src/Backends/SystemUpdate.vala:234 msgid "Resolving dependencies" -msgstr "" +msgstr "依存関係を解決しています" #: src/Backends/SystemUpdate.vala:236 msgid "Checking signatures" -msgstr "" +msgstr "署名を確認しています" #: src/Backends/SystemUpdate.vala:238 msgid "Testing changes" -msgstr "" +msgstr "変更をテストしています" #: src/Backends/SystemUpdate.vala:240 msgid "Committing changes" -msgstr "" +msgstr "変更を適用しています" #: src/Backends/SystemUpdate.vala:242 msgid "Requesting data" -msgstr "" +msgstr "データを要求しています" #: src/Backends/SystemUpdate.vala:244 msgid "Finished" -msgstr "" +msgstr "完了しました" #: src/Backends/SystemUpdate.vala:246 msgid "Cancelling" -msgstr "" +msgstr "キャンセルしています" #: src/Backends/SystemUpdate.vala:248 msgid "Downloading repository information" -msgstr "" +msgstr "リポジトリの情報をダウンロードしています" #: src/Backends/SystemUpdate.vala:250 msgid "Downloading list of packages" -msgstr "" +msgstr "パッケージの一覧をダウンロードしています" #: src/Backends/SystemUpdate.vala:252 msgid "Downloading file lists" -msgstr "" +msgstr "ファイルの一覧をダウンロードしています" #: src/Backends/SystemUpdate.vala:254 msgid "Downloading lists of changes" -msgstr "" +msgstr "変更の一覧をダウンロードしています" #: src/Backends/SystemUpdate.vala:256 msgid "Downloading groups" -msgstr "" +msgstr "グループをダウンロードしています" #: src/Backends/SystemUpdate.vala:258 msgid "Downloading update information" -msgstr "" +msgstr "アップデート情報をダウンロードしています" #: src/Backends/SystemUpdate.vala:260 msgid "Repackaging files" -msgstr "" +msgstr "ファイルを再パッケージしています" #: src/Backends/SystemUpdate.vala:262 msgid "Loading cache" -msgstr "" +msgstr "キャッシュを読み込んでいます" #: src/Backends/SystemUpdate.vala:264 msgid "Scanning applications" -msgstr "" +msgstr "アプリケーションをスキャンしています" #: src/Backends/SystemUpdate.vala:266 msgid "Generating package lists" -msgstr "" +msgstr "パッケージリストを生成しています" #: src/Backends/SystemUpdate.vala:268 msgid "Waiting for package manager lock" -msgstr "" +msgstr "パッケージマネージャーのロックを待機しています" #: src/Backends/SystemUpdate.vala:270 msgid "Waiting for authentication" -msgstr "" +msgstr "アプリが認証されるのを待機しています" #: src/Backends/SystemUpdate.vala:272 -#, fuzzy -#| msgid "Updated translations" msgid "Updating running applications" -msgstr "翻訳の更新" +msgstr "実行中のアプリケーションをアップデートしています" #: src/Backends/SystemUpdate.vala:274 msgid "Checking applications in use" -msgstr "" +msgstr "使用中のアプリケーションを確認しています" #: src/Backends/SystemUpdate.vala:276 msgid "Checking libraries in use" -msgstr "" +msgstr "使用中のライブラリを確認しています" #: src/Backends/SystemUpdate.vala:278 msgid "Copying files" -msgstr "" +msgstr "ファイルをコピーしています" #: src/Backends/SystemUpdate.vala:281 msgid "Installing" -msgstr "" +msgstr "インストールしています" diff --git a/src/Application.vala b/src/Application.vala index 3ec654b0..ebf7b212 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -13,13 +13,13 @@ public sealed class SettingsDaemon.Application : Gtk.Application { private Backends.KeyboardSettings keyboard_settings; private Backends.MouseSettings mouse_settings; - private Backends.InterfaceSettings interface_settings; private Backends.NightLightSettings night_light_settings; private Backends.PrefersColorSchemeSettings prefers_color_scheme_settings; private Backends.AccentColorManager accent_color_manager; private Backends.Housekeeping housekeeping; + private Backends.PowerProfilesSync power_profiles_sync; private const string FDO_ACCOUNTS_NAME = "org.freedesktop.Accounts"; private const string FDO_ACCOUNTS_PATH = "/org/freedesktop/Accounts"; @@ -55,6 +55,7 @@ public sealed class SettingsDaemon.Application : Gtk.Application { base.startup (); housekeeping = new Backends.Housekeeping (); + power_profiles_sync = new Backends.PowerProfilesSync (); var check_firmware_updates_action = new GLib.SimpleAction ("check-firmware-updates", null); check_firmware_updates_action.activate.connect (check_firmware_updates); diff --git a/src/Backends/PowerProfilesSync.vala b/src/Backends/PowerProfilesSync.vala new file mode 100644 index 00000000..09558ba7 --- /dev/null +++ b/src/Backends/PowerProfilesSync.vala @@ -0,0 +1,111 @@ +/* + * Copyright 2024 elementary, Inc. (https://elementary.io) + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +public class SettingsDaemon.Backends.PowerProfilesSync : GLib.Object { + [DBus (name = "org.freedesktop.UPower")] + private interface UPower : GLib.DBusProxy { + public abstract bool on_battery { get; } + } + + [DBus (name = "net.hadess.PowerProfiles")] + private interface PowerProfile : GLib.DBusProxy { + public abstract HashTable[] profiles { owned get; } + public abstract string active_profile { owned get; set; } + } + + private const string PROFILE_PLUGGED_IN = "profile-plugged-in"; + private const string PROFILE_ON_BATTERY = "profile-on-good-battery"; + + private GLib.Settings settings; + private UPower? upower = null; + private PowerProfile? power_profiles_daemon = null; + + construct { + settings = new GLib.Settings ("io.elementary.settings-daemon.power"); + + Bus.watch_name (BusType.SYSTEM, "org.freedesktop.UPower", BusNameWatcherFlags.NONE, on_upower_watch, on_upower_unwatch); + Bus.watch_name (BusType.SYSTEM, "net.hadess.PowerProfiles", BusNameWatcherFlags.NONE, on_ppd_watch, on_ppd_unwatch); + + settings.changed.connect (update_profile); + } + + private void on_upower_watch (GLib.DBusConnection connection) { + connection.get_proxy.begin ( + "org.freedesktop.UPower", "/org/freedesktop/UPower", NONE, null, + (obj, res) => { + try { + upower = ((GLib.DBusConnection) obj).get_proxy.end (res); + debug ("Connected to UPower"); + + update_profile (); + + upower.g_properties_changed.connect ((changed_properties) => { + for (int i = 0; i < changed_properties.n_children (); i++) { + unowned string property; + changed_properties.get_child (i, "{&sv}", out property, null); + if (property == "OnBattery") { + update_profile (); + break; + } + } + }); + } catch (Error e) { + critical (e.message); + upower = null; + } + } + ); + } + + private void on_upower_unwatch (GLib.DBusConnection connection) { + upower = null; + critical ("Lost connection to UPower"); + } + + private void on_ppd_watch (GLib.DBusConnection connection) { + connection.get_proxy.begin ( + "net.hadess.PowerProfiles", "/net/hadess/PowerProfiles", NONE, null, + (obj, res) => { + try { + power_profiles_daemon = ((GLib.DBusConnection) obj).get_proxy.end (res); + debug ("Connected to power profiles daemon"); + + update_profile (); + } catch (Error e) { + critical (e.message); + power_profiles_daemon = null; + } + } + ); + } + + private void on_ppd_unwatch (GLib.DBusConnection connection) { + power_profiles_daemon = null; + critical ("Lost connection to power profiles daemon"); + } + + private void update_profile () { + if (power_profiles_daemon == null || upower == null) { + return; + } + + var profile_to_set = settings.get_string (upower.on_battery ? PROFILE_ON_BATTERY : PROFILE_PLUGGED_IN); + + var found_profile = false; + var profiles = power_profiles_daemon.profiles; + for (int i = 0; i < profiles.length; i++) { + if (profiles[i].get ("Profile").get_string () == profile_to_set) { + found_profile = true; + break; + } + } + + if (found_profile) { + power_profiles_daemon.active_profile = profile_to_set; + } else { + warning ("Couldn't set power profile to %s", profile_to_set); + } + } +} diff --git a/src/meson.build b/src/meson.build index d9a4ec86..105bd0eb 100644 --- a/src/meson.build +++ b/src/meson.build @@ -7,6 +7,7 @@ sources = files( 'Backends/KeyboardSettings.vala', 'Backends/MouseSettings.vala', 'Backends/NightLightSettings.vala', + 'Backends/PowerProfilesSync.vala', 'Backends/PrefersColorSchemeSettings.vala', 'Backends/SystemUpdate.vala', 'Backends/UbuntuDrivers.vala',