forked from Shinonome/dots-hyprland
Ddcci fixes (#2562)
This commit is contained in:
@@ -48,6 +48,16 @@ Singleton {
|
|||||||
ddcProc.running = true;
|
ddcProc.running = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initializeMonitor(i: int): void {
|
||||||
|
if (i >= monitors.length)
|
||||||
|
return;
|
||||||
|
monitors[i].initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
function ddcDetectFinished(): void {
|
||||||
|
initializeMonitor(0);
|
||||||
|
}
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: ddcProc
|
id: ddcProc
|
||||||
|
|
||||||
@@ -58,13 +68,13 @@ Singleton {
|
|||||||
if (data.startsWith("Display ")) {
|
if (data.startsWith("Display ")) {
|
||||||
const lines = data.split("\n").map(l => l.trim());
|
const lines = data.split("\n").map(l => l.trim());
|
||||||
root.ddcMonitors.push({
|
root.ddcMonitors.push({
|
||||||
model: lines.find(l => l.startsWith("Monitor:")).split(":")[2],
|
name: lines.find(l => l.startsWith("DRM connector:")).split("-").slice(1).join('-'),
|
||||||
busNum: lines.find(l => l.startsWith("I2C bus:")).split("/dev/i2c-")[1]
|
busNum: lines.find(l => l.startsWith("I2C bus:")).split("/dev/i2c-")[1]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onExited: root.ddcMonitorsChanged()
|
onExited: root.ddcDetectFinished()
|
||||||
}
|
}
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
@@ -75,14 +85,8 @@ Singleton {
|
|||||||
id: monitor
|
id: monitor
|
||||||
|
|
||||||
required property ShellScreen screen
|
required property ShellScreen screen
|
||||||
readonly property bool isDdc: {
|
property bool isDdc
|
||||||
const match = root.ddcMonitors.find(m => m.model === screen.model && !root.monitors.slice(0, root.monitors.indexOf(this)).some(mon => mon.busNum === m.busNum));
|
property string busNum
|
||||||
return !!match;
|
|
||||||
}
|
|
||||||
readonly property string busNum: {
|
|
||||||
const match = root.ddcMonitors.find(m => m.model === screen.model && !root.monitors.slice(0, root.monitors.indexOf(this)).some(mon => mon.busNum === m.busNum));
|
|
||||||
return match?.busNum ?? "";
|
|
||||||
}
|
|
||||||
property int rawMaxBrightness: 100
|
property int rawMaxBrightness: 100
|
||||||
property real brightness
|
property real brightness
|
||||||
property real brightnessMultiplier: 1.0
|
property real brightnessMultiplier: 1.0
|
||||||
@@ -110,6 +114,9 @@ Singleton {
|
|||||||
|
|
||||||
function initialize() {
|
function initialize() {
|
||||||
monitor.ready = false;
|
monitor.ready = false;
|
||||||
|
const match = root.ddcMonitors.find(m => m.name === screen.name && !root.monitors.slice(0, root.monitors.indexOf(this)).some(mon => mon.busNum === m.busNum));
|
||||||
|
isDdc = !!match;
|
||||||
|
busNum = match?.busNum ?? "";
|
||||||
initProc.command = isDdc ? ["ddcutil", "-b", busNum, "getvcp", "10", "--brief"] : ["sh", "-c", `echo "a b c $(brightnessctl g) $(brightnessctl m)"`];
|
initProc.command = isDdc ? ["ddcutil", "-b", busNum, "getvcp", "10", "--brief"] : ["sh", "-c", `echo "a b c $(brightnessctl g) $(brightnessctl m)"`];
|
||||||
initProc.running = true;
|
initProc.running = true;
|
||||||
}
|
}
|
||||||
@@ -123,6 +130,9 @@ Singleton {
|
|||||||
monitor.ready = true;
|
monitor.ready = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
onExited: (exitCode, exitStatus) => {
|
||||||
|
initializeMonitor(root.monitors.indexOf(monitor) + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need a delay for DDC monitors because they can be quite slow and might act weird with rapid changes
|
// We need a delay for DDC monitors because they can be quite slow and might act weird with rapid changes
|
||||||
@@ -157,14 +167,6 @@ Singleton {
|
|||||||
function setBrightnessMultiplier(value: real): void {
|
function setBrightnessMultiplier(value: real): void {
|
||||||
monitor.brightnessMultiplier = value;
|
monitor.brightnessMultiplier = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
|
||||||
initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
onBusNumChanged: {
|
|
||||||
initialize();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
@@ -215,7 +217,7 @@ Singleton {
|
|||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: screenshotProc
|
id: screenshotProc
|
||||||
command: ["bash", "-c",
|
command: ["bash", "-c",
|
||||||
`mkdir -p '${StringUtils.shellSingleQuoteEscape(root.screenshotDir)}'`
|
`mkdir -p '${StringUtils.shellSingleQuoteEscape(root.screenshotDir)}'`
|
||||||
+ ` && grim -o '${StringUtils.shellSingleQuoteEscape(screenScope.screenName)}' -`
|
+ ` && grim -o '${StringUtils.shellSingleQuoteEscape(screenScope.screenName)}' -`
|
||||||
+ ` | magick png:- -colorspace Gray -format "%[fx:mean*100]" info:`
|
+ ` | magick png:- -colorspace Gray -format "%[fx:mean*100]" info:`
|
||||||
|
|||||||
Reference in New Issue
Block a user