mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
feat(brightness): change enforce minimum brightness method
This commit is contained in:
@@ -450,7 +450,6 @@ Singleton {
|
||||
}
|
||||
|
||||
readonly property real stepSize: Settings.data.brightness.brightnessStep / 100.0
|
||||
readonly property real minBrightnessValue: (Settings.data.brightness.enforceMinimum ? 0.01 : 0.0)
|
||||
|
||||
// Timer for debouncing rapid changes
|
||||
readonly property Timer timer: Timer {
|
||||
@@ -470,13 +469,7 @@ Singleton {
|
||||
|
||||
function increaseBrightness(): void {
|
||||
const value = !isNaN(monitor.queuedBrightness) ? monitor.queuedBrightness : monitor.brightness;
|
||||
// Enforce minimum brightness if enabled
|
||||
if (Settings.data.brightness.enforceMinimum && value < minBrightnessValue) {
|
||||
setBrightnessDebounced(Math.max(stepSize, minBrightnessValue));
|
||||
} else {
|
||||
// Normal brightness increase
|
||||
setBrightnessDebounced(value + stepSize);
|
||||
}
|
||||
setBrightnessDebounced(value + stepSize);
|
||||
}
|
||||
|
||||
function decreaseBrightness(): void {
|
||||
@@ -485,7 +478,7 @@ Singleton {
|
||||
}
|
||||
|
||||
function setBrightness(value: real): void {
|
||||
value = Math.max(minBrightnessValue, Math.min(1, value));
|
||||
value = Math.min(1, value);
|
||||
var rounded = Math.round(value * 100);
|
||||
|
||||
// Always update internal value and trigger UI feedback immediately
|
||||
@@ -522,11 +515,12 @@ Singleton {
|
||||
} else if (!isDdc) {
|
||||
monitor.commandRunning = true;
|
||||
monitor.ignoreNextChange = true;
|
||||
var setMin = Settings.data.brightness.enforceMinimum ? "-n" : "";
|
||||
var backlightDeviceName = root.getBacklightDeviceName(monitor.backlightDevice);
|
||||
if (backlightDeviceName !== "") {
|
||||
setBrightnessProc.command = ["brightnessctl", "-d", backlightDeviceName, "s", rounded + "%"];
|
||||
setBrightnessProc.command = ["brightnessctl", "-d", backlightDeviceName, "s", rounded + "%", setMin];
|
||||
} else {
|
||||
setBrightnessProc.command = ["brightnessctl", "s", rounded + "%"];
|
||||
setBrightnessProc.command = ["brightnessctl", "s", rounded + "%", setMin];
|
||||
}
|
||||
setBrightnessProc.running = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user