diff options
author | Andrej Valek <[email protected]> | 2020-04-19 19:16:55 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2020-05-25 15:28:13 +0200 |
commit | 3fb36a3dce47e86d3cf8f855ba56765aa4372ac6 (patch) | |
tree | 01f97db9c592813d18d5ef2ac7000003931ba22b /src | |
parent | b95595cc3dc7e216d67ddb9d9e1e5828639589ae (diff) | |
download | mate-power-manager-3fb36a3dce47e86d3cf8f855ba56765aa4372ac6.tar.bz2 mate-power-manager-3fb36a3dce47e86d3cf8f855ba56765aa4372ac6.tar.xz |
gpm-kbd-backlight: do not change keyboard back-light, when disabled
Automatically change keyboard back-light only when enabled on battery. Keep
previous brightness level between state change.
Signed-off-by: Andrej Valek <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/gpm-kbd-backlight.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/gpm-kbd-backlight.c b/src/gpm-kbd-backlight.c index 38da913..2b201f1 100644 --- a/src/gpm-kbd-backlight.c +++ b/src/gpm-kbd-backlight.c @@ -443,18 +443,24 @@ gpm_kbd_backlight_evaluate_power_source_and_set (GpmKbdBacklight *backlight) battery_reduce = g_settings_get_boolean (backlight->priv->settings, GPM_SETTINGS_KBD_BACKLIGHT_BATT_REDUCE); - if (on_battery && battery_reduce) { - value = g_settings_get_int (backlight->priv->settings, GPM_SETTINGS_KBD_BRIGHTNESS_DIM_BY_ON_BATT); + if (on_battery) { + if (battery_reduce) { + value = g_settings_get_int (backlight->priv->settings, GPM_SETTINGS_KBD_BRIGHTNESS_DIM_BY_ON_BATT); - if (value > 100) { - g_warning ("Cannot scale brightness down by more than 100%%. Scaling by 50%%"); - value = 50; - } + if (value > 100) { + g_warning ("Cannot scale brightness down by more than 100%%. Scaling by 50%%"); + value = 50; + } - scale = (100 - value) / 100.0f; - brightness *= scale; + scale = (100 - value) / 100.0f; + brightness *= scale; - value = (guint) brightness; + value = (guint) brightness; + + } else { + // do not change keyboard backlight + return TRUE; + } } else { value = g_settings_get_int (backlight->priv->settings, GPM_SETTINGS_KBD_BRIGHTNESS_ON_AC); @@ -583,6 +589,7 @@ gpm_kbd_backlight_idle_changed_cb (GpmIdle *idle, enable_action = on_battery ? g_settings_get_boolean (backlight->priv->settings, GPM_SETTINGS_IDLE_DIM_BATT) + && g_settings_get_boolean (backlight->priv->settings, GPM_SETTINGS_KBD_BACKLIGHT_BATT_REDUCE) : g_settings_get_boolean (backlight->priv->settings, GPM_SETTINGS_IDLE_DIM_AC); if (!enable_action) |