[gnome-settings-daemon/wip/hadess/force-screensaver-power-saver: 1/2] power: Dim screen faster if power saver mode is on
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon/wip/hadess/force-screensaver-power-saver: 1/2] power: Dim screen faster if power saver mode is on
- Date: Thu, 29 Jul 2021 10:09:53 +0000 (UTC)
commit 4b027055bddcd5a5cf5306a0828f8710f4ca3e96
Author: Bastien Nocera <hadess hadess net>
Date: Wed Jul 28 16:40:24 2021 +0200
power: Dim screen faster if power saver mode is on
As done on other platforms, aggressively dim the screen after a
short period when the user has selected to enter power saver mode.
Idle inhibitions are obviously still respected.
Prior art:
https://support.apple.com/en-us/HT205234
plugins/power/gsd-power-manager.c | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
---
diff --git a/plugins/power/gsd-power-manager.c b/plugins/power/gsd-power-manager.c
index 1f125a6f..cf6f5a57 100644
--- a/plugins/power/gsd-power-manager.c
+++ b/plugins/power/gsd-power-manager.c
@@ -192,6 +192,7 @@ struct _GsdPowerManager
/* Power Profiles */
GDBusProxy *power_profiles_proxy;
guint32 power_saver_cookie;
+ gboolean power_saver_enabled;
/* Sound */
guint32 critical_alert_timeout_id;
@@ -1903,7 +1904,8 @@ idle_configure (GsdPowerManager *manager)
/* Don't dim when the screen lock is active */
} else if (!on_battery) {
/* Don't dim when charging */
- } else if (manager->battery_is_low) {
+ } else if (manager->battery_is_low ||
+ manager->power_saver_enabled) {
/* Aggressively blank when battery is low */
timeout_dim = SCREENSAVER_TIMEOUT_BLANK;
} else {
@@ -2165,6 +2167,30 @@ power_profiles_proxy_signal_cb (GDBusProxy *proxy,
manager->power_saver_cookie = 0;
}
+static void
+power_profiles_proxy_properties_changed_cb (GDBusProxy *proxy,
+ GVariant *changed_properties,
+ GStrv invalidated_properties,
+ gpointer user_data)
+{
+ GsdPowerManager *manager = user_data;
+ g_autoptr(GVariant) v = NULL;
+ const char *active_profile;
+ gboolean power_saver_enabled;
+
+ if (!changed_properties)
+ return;
+ v = g_dbus_proxy_get_cached_property (proxy, "ActiveProfile");
+ if (!v)
+ return;
+ active_profile = g_variant_get_string (v, NULL);
+ power_saver_enabled = g_strcmp0 (active_profile, "power-saver") == 0;
+ if (power_saver_enabled != manager->power_saver_enabled) {
+ manager->power_saver_enabled = power_saver_enabled;
+ idle_configure (manager);
+ }
+}
+
static void
power_profiles_proxy_ready_cb (GObject *source_object,
GAsyncResult *res,
@@ -2179,6 +2205,9 @@ power_profiles_proxy_ready_cb (GObject *source_object,
return;
}
+ g_signal_connect (manager->power_profiles_proxy, "g-properties-changed",
+ G_CALLBACK (power_profiles_proxy_properties_changed_cb),
+ manager);
g_signal_connect (manager->power_profiles_proxy, "g-signal",
G_CALLBACK (power_profiles_proxy_signal_cb),
manager);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]