diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-07-26 13:16:18 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-07-26 13:16:18 +1000 |
| commit | 67d229c702a7422b5a996730577ebdb8eef1f8c5 (patch) | |
| tree | 4160a84890c54668cced5108c0b43e3b31cf15c2 /services/Brightness.qml | |
| parent | ci: add flake update action (#267) (diff) | |
| download | caelestia-shell-67d229c702a7422b5a996730577ebdb8eef1f8c5.tar.gz caelestia-shell-67d229c702a7422b5a996730577ebdb8eef1f8c5.tar.bz2 caelestia-shell-67d229c702a7422b5a996730577ebdb8eef1f8c5.zip | |
brightness: debounce ddc changes
Diffstat (limited to 'services/Brightness.qml')
| -rw-r--r-- | services/Brightness.qml | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/services/Brightness.qml b/services/Brightness.qml index eab5468..4654996 100644 --- a/services/Brightness.qml +++ b/services/Brightness.qml @@ -86,6 +86,7 @@ Singleton { readonly property string busNum: root.ddcMonitors.find(m => m.model === modelData.model)?.busNum ?? "" readonly property bool isAppleDisplay: root.appleDisplayPresent && modelData.model.startsWith("StudioDisplay") property real brightness + property real queuedBrightness readonly property Process initProc: Process { stdout: StdioCollector { @@ -101,11 +102,22 @@ Singleton { } } + readonly property Timer timer: Timer { + interval: 500 + onTriggered: monitor.setBrightness(monitor.queuedBrightness) + } + function setBrightness(value: real): void { value = Math.max(0, Math.min(1, value)); const rounded = Math.round(value * 100); if (Math.round(brightness * 100) === rounded) return; + + if (isDdc && timer.running) { + queuedBrightness = value; + return; + } + brightness = value; if (isAppleDisplay) @@ -114,6 +126,8 @@ Singleton { Quickshell.execDetached(["ddcutil", "-b", busNum, "setvcp", "10", rounded]); else Quickshell.execDetached(["brightnessctl", "s", `${rounded}%`]); + + timer.restart(); } function initBrightness(): void { |