From 47d7a4b03e576e696e97fc3e7e90812833ecb671 Mon Sep 17 00:00:00 2001 From: Felipe Borges Date: Tue, 10 Sep 2024 14:29:56 +0200 Subject: [PATCH] power: Read downstream sleep-inactive-ac-type-server gsetting We have a downstream side-setting for when the hostnamed chassis type is "server". This allows for having a different "default" in each chassis-type. --- panels/power/cc-power-panel.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c index a17e8490c..f7bf72be1 100644 --- a/panels/power/cc-power-panel.c +++ b/panels/power/cc-power-panel.c @@ -462,8 +462,11 @@ update_automatic_suspend_label (CcPowerPanel *self) gint ac_timeout; gint battery_timeout; const gchar *s; + gboolean is_server = FALSE; - ac_action = g_settings_get_enum (self->gsd_settings, "sleep-inactive-ac-type"); + is_server = g_strcmp0 (self->chassis_type, "server") == 0; + + ac_action = g_settings_get_enum (self->gsd_settings, is_server ? "sleep-inactive-ac-type-server" : "sleep-inactive-ac-type"); battery_action = g_settings_get_enum (self->gsd_settings, "sleep-inactive-battery-type"); ac_timeout = g_settings_get_int (self->gsd_settings, "sleep-inactive-ac-timeout"); battery_timeout = g_settings_get_int (self->gsd_settings, "sleep-inactive-battery-timeout"); @@ -621,6 +624,9 @@ setup_power_saving (CcPowerPanel *self) { g_autoptr(GDBusConnection) connection = NULL; g_autoptr(GError) error = NULL; + gboolean is_server = FALSE; + + is_server = g_strcmp0 (self->chassis_type, "server") == 0; /* ambient light sensor */ self->iio_proxy_watch_id = @@ -674,7 +680,7 @@ setup_power_saving (CcPowerPanel *self) */ if (g_settings_get_int (self->gsd_settings, "sleep-inactive-ac-timeout") == 0) { - g_settings_set_enum (self->gsd_settings, "sleep-inactive-ac-type", GSD_POWER_ACTION_NOTHING); + g_settings_set_enum (self->gsd_settings, is_server ? "sleep-inactive-ac-type-server" : "sleep-inactive-ac-type", GSD_POWER_ACTION_NOTHING); g_settings_set_int (self->gsd_settings, "sleep-inactive-ac-timeout", 3600); } if (g_settings_get_int (self->gsd_settings, "sleep-inactive-battery-timeout") == 0) @@ -696,7 +702,7 @@ setup_power_saving (CcPowerPanel *self) G_SETTINGS_BIND_DEFAULT, get_sleep_type, set_sleep_type, NULL, NULL); - g_settings_bind_with_mapping (self->gsd_settings, "sleep-inactive-ac-type", + g_settings_bind_with_mapping (self->gsd_settings, is_server ? "sleep-inactive-ac-type-server" : "sleep-inactive-ac-type", self->suspend_on_ac_switch_row, "active", G_SETTINGS_BIND_DEFAULT, get_sleep_type, set_sleep_type, NULL, NULL); -- 2.46.2