Brightness: brings back realtime brightness monitoring for internal(laptop) display.

The pill will open and show the change in real time
This commit is contained in:
LemmyCook 2025-09-06 19:27:32 -04:00
parent 9bc6479c92
commit 36d3a50f21
2 changed files with 70 additions and 28 deletions

View file

@ -37,28 +37,26 @@ Item {
target: getMonitor()
ignoreUnknownSignals: true
function onBrightnessUpdated() {
Logger.log("Bar-Brightness", "OnBrightnessUpdated")
var monitor = getMonitor()
if (!monitor)
return
var currentBrightness = monitor.brightness
// Ignore if this is the first time or if brightness hasn't actually changed
// Ignore if this is the first time we receive an update.
// Most likely service just kicked off.
if (!firstBrightnessReceived) {
firstBrightnessReceived = true
monitor.lastBrightness = currentBrightness
return
}
// Only show pill if brightness actually changed (not just loaded from settings)
if (Math.abs(currentBrightness - monitor.lastBrightness) > 0.1) {
pill.show()
}
monitor.lastBrightness = currentBrightness
pill.show()
hideTimerAfterChange.restart()
}
}
Timer {
id: hideTimerAfterChange
interval: 2500
running: false
repeat: false
onTriggered: pill.hide()
}
NPill {
id: pill