forked from Shinonome/dots-hyprland
brightness: delay setting for ddc monitors (#2022)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user