feat(brightness): change enforce minimum brightness method

This commit is contained in:
ern775
2026-04-07 22:34:11 +03:00
parent 91d0bb83ae
commit 15873d4818
3 changed files with 7 additions and 13 deletions
+1 -1
View File
@@ -57,7 +57,7 @@ NBox {
running: false
repeat: false
onTriggered: {
if (brightnessMonitor && Math.abs(localBrightness - brightnessMonitor.brightness) >= 0.01) {
if (brightnessMonitor && Math.abs(localBrightness - brightnessMonitor.brightness) > 0.009) {
brightnessMonitor.setBrightness(localBrightness);
}
}
+1 -1
View File
@@ -74,7 +74,7 @@ SmartPanel {
id: playerContent
anchors.fill: parent
property real contentPreferredHeight: mainLayout.implicitHeight + Style.margin2L;
property real contentPreferredHeight: mainLayout.implicitHeight + Style.margin2L
property Component visualizerSource: {
switch (root.visualizerType) {
+5 -11
View File
@@ -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;
}