summaryrefslogtreecommitdiff
path: root/src/gpm-kbd-backlight.c
diff options
context:
space:
mode:
authorAndrej Valek <[email protected]>2020-04-19 19:16:55 +0200
committerraveit65 <[email protected]>2020-05-25 15:28:13 +0200
commit3fb36a3dce47e86d3cf8f855ba56765aa4372ac6 (patch)
tree01f97db9c592813d18d5ef2ac7000003931ba22b /src/gpm-kbd-backlight.c
parentb95595cc3dc7e216d67ddb9d9e1e5828639589ae (diff)
downloadmate-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/gpm-kbd-backlight.c')
-rw-r--r--src/gpm-kbd-backlight.c25
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)