forked from Shinonome/dots-hyprland
fix(brightness): use the monitor's max brightness instead of '100' (#1966)
This commit is contained in:
@@ -76,6 +76,7 @@ Singleton {
|
|||||||
required property ShellScreen screen
|
required property ShellScreen screen
|
||||||
readonly property bool isDdc: root.ddcMonitors.some(m => m.model === screen.model)
|
readonly property bool isDdc: root.ddcMonitors.some(m => m.model === screen.model)
|
||||||
readonly property string busNum: root.ddcMonitors.find(m => m.model === screen.model)?.busNum ?? ""
|
readonly property string busNum: root.ddcMonitors.find(m => m.model === screen.model)?.busNum ?? ""
|
||||||
|
property int rawMaxBrightness: 100
|
||||||
property real brightness
|
property real brightness
|
||||||
property bool ready: false
|
property bool ready: false
|
||||||
|
|
||||||
@@ -95,7 +96,8 @@ Singleton {
|
|||||||
stdout: SplitParser {
|
stdout: SplitParser {
|
||||||
onRead: data => {
|
onRead: data => {
|
||||||
const [, , , current, max] = data.split(" ");
|
const [, , , current, max] = data.split(" ");
|
||||||
monitor.brightness = parseInt(current) / parseInt(max);
|
monitor.rawMaxBrightness = parseInt(max);
|
||||||
|
monitor.brightness = parseInt(current) / monitor.rawMaxBrightness;
|
||||||
monitor.ready = true;
|
monitor.ready = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,11 +105,11 @@ Singleton {
|
|||||||
|
|
||||||
function setBrightness(value: real): void {
|
function setBrightness(value: real): void {
|
||||||
value = Math.max(0.01, Math.min(1, value));
|
value = Math.max(0.01, Math.min(1, value));
|
||||||
const rounded = Math.round(value * 100);
|
const rounded = Math.round(value * monitor.rawMaxBrightness);
|
||||||
if (Math.round(brightness * 100) === rounded)
|
if (Math.round(brightness * monitor.rawMaxBrightness) === rounded)
|
||||||
return;
|
return;
|
||||||
brightness = value;
|
brightness = value;
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user