BrightnessService: add minimum brightness to prevent backlight from turning off

This commit is contained in:
Sighthesia
2025-10-23 13:46:09 +08:00
parent c3439b262c
commit e9f4badec5
+9 -2
View File
@@ -253,7 +253,13 @@ Singleton {
function increaseBrightness(): void {
const value = !isNaN(monitor.queuedBrightness) ? monitor.queuedBrightness : monitor.brightness
setBrightnessDebounced(value + stepSize)
// Set to step size if currently at minimum brightness
if (value <= 0.01) {
setBrightnessDebounced(Math.max(stepSize, 0.01))
} else {
// Normal brightness increase
setBrightnessDebounced(value + stepSize)
}
}
function decreaseBrightness(): void {
@@ -262,7 +268,8 @@ Singleton {
}
function setBrightness(value: real): void {
value = Math.max(0, Math.min(1, value))
// Enforce a minimum brightness of 1% (0.01) to avoid completely turning off the backlight
value = Math.max(0.01, Math.min(1, value))
var rounded = Math.round(value * 100)
if (timer.running) {