From 593821e998415ae2a9861a9f894f7bd59c4373fe Mon Sep 17 00:00:00 2001 From: quadbyte Date: Sun, 17 Aug 2025 07:44:40 -0400 Subject: [PATCH] Brightness improvements - we dont want to save brightness in settings as it is saved in the hardware - fixed a few DDCutil weirdness --- Commons/Settings.qml | 3 -- Modules/Bar/Brightness.qml | 2 +- Services/BrightnessService.qml | 60 ++++------------------------------ 3 files changed, 7 insertions(+), 58 deletions(-) diff --git a/Commons/Settings.qml b/Commons/Settings.qml index be7f21b..b4048a7 100644 --- a/Commons/Settings.qml +++ b/Commons/Settings.qml @@ -188,9 +188,6 @@ Singleton { property JsonObject brightness brightness: JsonObject { - property real lastBrightness: 50.0 - property string lastMethod: "internal" - property list monitorBrightness: [] property int brightnessStep: 5 } diff --git a/Modules/Bar/Brightness.qml b/Modules/Bar/Brightness.qml index 7d47b53..882fb49 100644 --- a/Modules/Bar/Brightness.qml +++ b/Modules/Bar/Brightness.qml @@ -10,7 +10,7 @@ Item { width: pill.width height: pill.height - visible: Settings.data.bar.showBrightness + visible: Settings.data.bar.showBrightness && firstBrightnessReceived // Used to avoid opening the pill on Quickshell startup property bool firstBrightnessReceived: false diff --git a/Services/BrightnessService.qml b/Services/BrightnessService.qml index ea8d9b8..d0fffb1 100644 --- a/Services/BrightnessService.qml +++ b/Services/BrightnessService.qml @@ -85,7 +85,7 @@ Singleton { readonly property bool isAppleDisplay: root.appleDisplayPresent && modelData.model.startsWith("StudioDisplay") readonly property string method: isAppleDisplay ? "apple" : (isDdc ? "ddcutil" : "internal") - property real brightness: getStoredBrightness() + property real brightness property real lastBrightness: 0 property real queuedBrightness: NaN @@ -110,9 +110,9 @@ Singleton { } } else if (monitor.isDdc) { var parts = dataText.split(" ") - if (parts.length >= 2) { - var current = parseInt(parts[0]) - var max = parseInt(parts[1]) + if (parts.length >= 4) { + var current = parseInt(parts[3]) + var max = parseInt(parts[4]) if (!isNaN(current) && !isNaN(max) && max > 0) { monitor.brightness = current / max Logger.log("Brightness", "DDC brightness:", current + "/" + max + " =", monitor.brightness) @@ -131,11 +131,8 @@ Singleton { } } - if (monitor.brightness > 0) { - // Save the detected brightness to settings - monitor.saveBrightness(monitor.brightness) - monitor.brightnessUpdated(monitor.brightness) - } + // Always update + monitor.brightnessUpdated(monitor.brightness) } } } @@ -161,48 +158,6 @@ Singleton { setBrightnessDebounced(monitor.brightness - stepSize) } - function getStoredBrightness(): real { - // Try to get stored brightness for this specific monitor - var stored = Settings.data.brightness.monitorBrightness.find(m => { - if (m !== null) { - return m.name === modelData.name - } - return false - }) - if (stored) { - return stored.brightness / 100 - } - // Fallback to general last brightness - return Settings.data.brightness.lastBrightness / 100 - } - - function saveBrightness(value: real): void { - var brightnessPercent = Math.round(value * 100) - - // Update general last brightness - Settings.data.brightness.lastBrightness = brightnessPercent - Settings.data.brightness.lastMethod = method - - // Update monitor-specific brightness - var monitorIndex = Settings.data.brightness.monitorBrightness.findIndex(m => { - if (m !== null) { - return m.name === modelData.name - } - return -1 - }) - var monitorData = { - "name": modelData.name, - "brightness": brightnessPercent, - "method": method - } - - if (monitorIndex >= 0) { - Settings.data.brightness.monitorBrightness[monitorIndex] = monitorData - } else { - Settings.data.brightness.monitorBrightness.push(monitorData) - } - } - function setBrightness(value: real): void { value = Math.max(0, Math.min(1, value)) var rounded = Math.round(value * 100) @@ -218,9 +173,6 @@ Singleton { brightness = value brightnessUpdated(brightness) - // Save to settings - saveBrightness(value) - if (isAppleDisplay) { Quickshell.execDetached(["asdbctl", "set", rounded]) } else if (isDdc) {