mirror of
https://github.com/end-4/dots-hyprland.git
synced 2026-06-05 14:59:27 -05:00
brightness: delay setting for ddc monitors (#2022)
This commit is contained in:
@@ -103,16 +103,27 @@ Singleton {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setBrightness(value: real): void {
|
// We need a delay for DDC monitors because they can be quite slow and might act weird with rapid changes
|
||||||
value = Math.max(0.01, Math.min(1, value));
|
property var setTimer: Timer {
|
||||||
const rounded = Math.round(value * monitor.rawMaxBrightness);
|
id: setTimer
|
||||||
if (Math.round(brightness * monitor.rawMaxBrightness) === rounded)
|
interval: monitor.isDdc ? 300 : 0
|
||||||
return;
|
onTriggered: {
|
||||||
brightness = value;
|
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.command = isDdc ? ["ddcutil", "-b", busNum, "setvcp", "10", rounded] : ["brightnessctl", "s", rounded, "--quiet"];
|
||||||
setProc.startDetached();
|
setProc.startDetached();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setBrightness(value: real): void {
|
||||||
|
value = Math.max(0.01, Math.min(1, value));
|
||||||
|
monitor.brightness = value;
|
||||||
|
setTimer.restart();
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user