From fb81961ba88c70adc8ccabdb1b60786d1276108a 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 | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c index 544cfd9be..bc320f9ef 100644 --- a/panels/power/cc-power-panel.c +++ b/panels/power/cc-power-panel.c @@ -625,8 +625,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"); @@ -781,6 +784,9 @@ setup_power_saving (CcPowerPanel *self) g_autoptr(GDBusConnection) connection = NULL; g_autoptr(GError) error = NULL; int value; + gboolean is_server = FALSE; + + is_server = g_strcmp0 (self->chassis_type, "server") == 0; /* ambient light sensor */ self->iio_proxy_watch_id = @@ -838,7 +844,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) @@ -860,15 +866,7 @@ setup_power_saving (CcPowerPanel *self) G_SETTINGS_BIND_DEFAULT, get_sleep_type, set_sleep_type, NULL, NULL); - g_object_set_data (G_OBJECT (self->suspend_on_battery_delay_combo), "_gsettings_key", "sleep-inactive-battery-timeout"); - value = g_settings_get_int (self->gsd_settings, "sleep-inactive-battery-timeout"); - set_value_for_combo (self->suspend_on_battery_delay_combo, value); - g_signal_connect_object (self->suspend_on_battery_delay_combo, "changed", - G_CALLBACK (combo_time_changed_cb), self, G_CONNECT_SWAPPED); - g_object_bind_property (self->suspend_on_battery_switch_row, "active", self->suspend_on_battery_delay_combo, "sensitive", - G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); - - 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.45.2