Skip to content

Commit 15873d4

Browse files
committed
feat(brightness): change enforce minimum brightness method
1 parent 91d0bb8 commit 15873d4

3 files changed

Lines changed: 7 additions & 13 deletions

File tree

Modules/Cards/BrightnessCard.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ NBox {
5757
running: false
5858
repeat: false
5959
onTriggered: {
60-
if (brightnessMonitor && Math.abs(localBrightness - brightnessMonitor.brightness) >= 0.01) {
60+
if (brightnessMonitor && Math.abs(localBrightness - brightnessMonitor.brightness) > 0.009) {
6161
brightnessMonitor.setBrightness(localBrightness);
6262
}
6363
}

Modules/Panels/Media/MediaPlayerPanel.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ SmartPanel {
7474
id: playerContent
7575
anchors.fill: parent
7676

77-
property real contentPreferredHeight: mainLayout.implicitHeight + Style.margin2L;
77+
property real contentPreferredHeight: mainLayout.implicitHeight + Style.margin2L
7878

7979
property Component visualizerSource: {
8080
switch (root.visualizerType) {

Services/Hardware/BrightnessService.qml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,6 @@ Singleton {
450450
}
451451

452452
readonly property real stepSize: Settings.data.brightness.brightnessStep / 100.0
453-
readonly property real minBrightnessValue: (Settings.data.brightness.enforceMinimum ? 0.01 : 0.0)
454453

455454
// Timer for debouncing rapid changes
456455
readonly property Timer timer: Timer {
@@ -470,13 +469,7 @@ Singleton {
470469

471470
function increaseBrightness(): void {
472471
const value = !isNaN(monitor.queuedBrightness) ? monitor.queuedBrightness : monitor.brightness;
473-
// Enforce minimum brightness if enabled
474-
if (Settings.data.brightness.enforceMinimum && value < minBrightnessValue) {
475-
setBrightnessDebounced(Math.max(stepSize, minBrightnessValue));
476-
} else {
477-
// Normal brightness increase
478-
setBrightnessDebounced(value + stepSize);
479-
}
472+
setBrightnessDebounced(value + stepSize);
480473
}
481474

482475
function decreaseBrightness(): void {
@@ -485,7 +478,7 @@ Singleton {
485478
}
486479

487480
function setBrightness(value: real): void {
488-
value = Math.max(minBrightnessValue, Math.min(1, value));
481+
value = Math.min(1, value);
489482
var rounded = Math.round(value * 100);
490483

491484
// Always update internal value and trigger UI feedback immediately
@@ -522,11 +515,12 @@ Singleton {
522515
} else if (!isDdc) {
523516
monitor.commandRunning = true;
524517
monitor.ignoreNextChange = true;
518+
var setMin = Settings.data.brightness.enforceMinimum ? "-n" : "";
525519
var backlightDeviceName = root.getBacklightDeviceName(monitor.backlightDevice);
526520
if (backlightDeviceName !== "") {
527-
setBrightnessProc.command = ["brightnessctl", "-d", backlightDeviceName, "s", rounded + "%"];
521+
setBrightnessProc.command = ["brightnessctl", "-d", backlightDeviceName, "s", rounded + "%", setMin];
528522
} else {
529-
setBrightnessProc.command = ["brightnessctl", "s", rounded + "%"];
523+
setBrightnessProc.command = ["brightnessctl", "s", rounded + "%", setMin];
530524
}
531525
setBrightnessProc.running = true;
532526
}

0 commit comments

Comments
 (0)