forked from Shinonome/dots-hyprland
brightness: animate change for laptop screens, prevent pitch black w/ anti flashbang
This commit is contained in:
@@ -90,12 +90,25 @@ Singleton {
|
|||||||
property real brightnessMultiplier: 1.0
|
property real brightnessMultiplier: 1.0
|
||||||
property real multipliedBrightness: Math.max(0, Math.min(1, brightness * brightnessMultiplier))
|
property real multipliedBrightness: Math.max(0, Math.min(1, brightness * brightnessMultiplier))
|
||||||
property bool ready: false
|
property bool ready: false
|
||||||
|
property bool animateChanges: !monitor.isDdc
|
||||||
|
|
||||||
onBrightnessChanged: {
|
onBrightnessChanged: {
|
||||||
if (monitor.ready) {
|
if (!monitor.ready) return;
|
||||||
root.brightnessChanged();
|
root.brightnessChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
Behavior on multipliedBrightness {
|
||||||
|
enabled: monitor.animateChanges
|
||||||
|
NumberAnimation {
|
||||||
|
duration: 200
|
||||||
|
easing.type: Easing.BezierSpline
|
||||||
|
easing.bezierCurve: Appearance.animationCurves.expressiveEffects
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onMultipliedBrightnessChanged: {
|
||||||
|
if (monitor.animationEnabled) syncBrightness();
|
||||||
|
else setTimer.restart();
|
||||||
|
}
|
||||||
|
|
||||||
function initialize() {
|
function initialize() {
|
||||||
monitor.ready = false;
|
monitor.ready = false;
|
||||||
@@ -124,7 +137,7 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function syncBrightness() {
|
function syncBrightness() {
|
||||||
const brightnessValue = monitor.multipliedBrightness
|
const brightnessValue = Math.max(monitor.multipliedBrightness, root.minimumBrightnessAllowed)
|
||||||
const rounded = Math.round(brightnessValue * monitor.rawMaxBrightness);
|
const rounded = Math.round(brightnessValue * monitor.rawMaxBrightness);
|
||||||
setProc.command = isDdc ? ["ddcutil", "-b", busNum, "setvcp", "10", rounded] : ["brightnessctl", "--class", "backlight", "s", rounded, "--quiet"];
|
setProc.command = isDdc ? ["ddcutil", "-b", busNum, "setvcp", "10", rounded] : ["brightnessctl", "--class", "backlight", "s", rounded, "--quiet"];
|
||||||
setProc.startDetached();
|
setProc.startDetached();
|
||||||
@@ -133,12 +146,10 @@ Singleton {
|
|||||||
function setBrightness(value: real): void {
|
function setBrightness(value: real): void {
|
||||||
value = Math.max(root.minimumBrightnessAllowed, Math.min(1, value));
|
value = Math.max(root.minimumBrightnessAllowed, Math.min(1, value));
|
||||||
monitor.brightness = value;
|
monitor.brightness = value;
|
||||||
setTimer.restart();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function setBrightnessMultiplier(value: real): void {
|
function setBrightnessMultiplier(value: real): void {
|
||||||
monitor.brightnessMultiplier = value;
|
monitor.brightnessMultiplier = value;
|
||||||
setTimer.restart();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
|||||||
Reference in New Issue
Block a user