Skip to content

Commit

Permalink
Option to limit max backlight level #3559
Browse files Browse the repository at this point in the history
  • Loading branch information
seerge committed Jan 8, 2025
1 parent fbdf853 commit 3feae30
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/Input/InputDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -916,11 +916,12 @@ public static void SetBacklight(int delta, bool force = false)
bool onBattery = SystemInformation.PowerStatus.PowerLineStatus != PowerLineStatus.Online;

int backlight = onBattery ? backlight_battery : backlight_power;
int backlightMax = AppConfig.Get("max_brightness", 3);

if (delta >= 4)
backlight = ++backlight % 4;
if (delta > backlightMax)
backlight = ++backlight % (backlightMax + 1);
else
backlight = Math.Max(Math.Min(3, backlight + delta), 0);
backlight = Math.Max(Math.Min(backlightMax, backlight + delta), 0);

if (onBattery)
AppConfig.Set("keyboard_brightness_ac", backlight);
Expand Down

0 comments on commit 3feae30

Please sign in to comment.