brightness: delay setting for ddc monitors (#2022)

This commit is contained in:
end-4
2025-09-20 10:37:24 +02:00
parent ed8e4b8766
commit b9ae5cafa0
+17 -6
View File
@@ -103,16 +103,27 @@ Singleton {
}
}
function setBrightness(value: real): void {
value = Math.max(0.01, Math.min(1, value));
const rounded = Math.round(value * monitor.rawMaxBrightness);
if (Math.round(brightness * monitor.rawMaxBrightness) === rounded)
return;
brightness = value;
// We need a delay for DDC monitors because they can be quite slow and might act weird with rapid changes
property var setTimer: Timer {
id: setTimer
interval: monitor.isDdc ? 300 : 0
onTriggered: {
syncBrightness();
}
}
function syncBrightness() {
const rounded = Math.round(monitor.brightness * monitor.rawMaxBrightness);
setProc.command = isDdc ? ["ddcutil", "-b", busNum, "setvcp", "10", rounded] : ["brightnessctl", "s", rounded, "--quiet"];
setProc.startDetached();
}
function setBrightness(value: real): void {
value = Math.max(0.01, Math.min(1, value));
monitor.brightness = value;
setTimer.restart();
}
Component.onCompleted: {
initialize();
}