brightness: use connector name to distinguish different monitors

One may have multiple monitors of the same model
This commit is contained in:
Moeta Yuko
2025-11-24 12:51:21 +00:00
parent c78c363388
commit 1836a2ff1c
@@ -58,7 +58,7 @@ 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]
}); });
} }
@@ -76,11 +76,11 @@ Singleton {
required property ShellScreen screen required property ShellScreen screen
readonly property bool isDdc: { readonly 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)); const match = root.ddcMonitors.find(m => m.name === screen.name && !root.monitors.slice(0, root.monitors.indexOf(this)).some(mon => mon.busNum === m.busNum));
return !!match; return !!match;
} }
readonly property string busNum: { 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)); const match = root.ddcMonitors.find(m => m.name === screen.name && !root.monitors.slice(0, root.monitors.indexOf(this)).some(mon => mon.busNum === m.busNum));
return match?.busNum ?? ""; return match?.busNum ?? "";
} }
property int rawMaxBrightness: 100 property int rawMaxBrightness: 100