1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-08-01 19:18:28 -04:00

display config: fix mixed ID/model identifiers

fixes #2736
This commit is contained in:
bbedward
2026-07-04 13:24:53 -04:00
parent e7bd8e4002
commit 65c4167ab2
4 changed files with 32 additions and 10 deletions
@@ -402,6 +402,17 @@ Singleton {
}
// Convert monitors.json config entry → internal outputsData map
function profileKeyMatchesOutput(outputId, output, name) {
if (name === outputId || getOutputIdentifier(output, name) === outputId)
return true;
if (!outputId.startsWith("desc:") || !output?.make)
return false;
const want = outputId.slice(5).trim();
const full = [output.make, output.model, output.serial].filter(p => p).join(" ").replace(/,/g, "");
const noSerial = [output.make, output.model].filter(p => p).join(" ").replace(/,/g, "");
return want === full || want === noSerial || full.startsWith(want + " ");
}
function generateOutputsDataFromConfig(configEntry) {
const result = {};
const cfgOutputs = configEntry.outputs || {};
@@ -410,20 +421,20 @@ Singleton {
// Find matching live output to get modes list
let liveOutput = null;
for (const name in outputs) {
if (getOutputIdentifier(outputs[name], name) === outputId || name === outputId) {
if (profileKeyMatchesOutput(outputId, outputs[name], name)) {
liveOutput = outputs[name];
break;
}
}
const liveModes = liveOutput?.modes || [];
let currentMode = liveModes.findIndex(m => {
const currentMode = liveModes.findIndex(m => {
const s = m.width + "x" + m.height + "@" + (m.refresh_rate / 1000).toFixed(3);
return s === cfg.mode;
});
if (currentMode < 0 && liveModes.length > 0)
currentMode = 0;
const entry = {
"name": outputId,
"explicitIdentifier": true,
"configured_mode": cfg.mode || "",
"make": liveOutput?.make || "",
"model": liveOutput?.model || "",
"serial": liveOutput?.serial || "",
@@ -1846,7 +1857,7 @@ Singleton {
function getHyprlandOutputIdentifier(output, outputName) {
if (SettingsData.displayNameMode === "model" && output?.make && output?.model)
return ("desc:" + output.make + " " + output.model + " " + (output?.serial || "Unknown")).replace(/,/g, "");
return ("desc:" + [output.make, output.model, output.serial].filter(p => p).join(" ")).replace(/,/g, "");
return outputName;
}
+5 -3
View File
@@ -105,8 +105,10 @@ Singleton {
}
function getOutputIdentifier(output, outputName) {
if (output.explicitIdentifier)
return outputName;
if (SettingsData.displayNameMode === "model" && output.make && output.model)
return ("desc:" + output.make + " " + output.model + " " + (output.serial || "Unknown")).replace(/,/g, "");
return ("desc:" + [output.make, output.model, output.serial].filter(p => p).join(" ")).replace(/,/g, "");
return outputName;
}
@@ -194,8 +196,8 @@ Singleton {
continue;
}
let resolution = "preferred";
if (output.modes && output.current_mode !== undefined) {
let resolution = output.configured_mode || "preferred";
if (!output.configured_mode && output.modes && output.current_mode !== undefined) {
const mode = output.modes[output.current_mode];
if (mode)
resolution = mode.width + "x" + mode.height + "@" + (mode.refresh_rate / 1000).toFixed(3);
+6 -1
View File
@@ -542,7 +542,12 @@ Singleton {
let width = 1920;
let height = 1080;
let refreshRate = 60;
if (output.modes && output.current_mode !== undefined) {
const configured = (output.configured_mode || "").match(/^(\d+)x(\d+)@([\d.]+)$/);
if (configured) {
width = parseInt(configured[1], 10);
height = parseInt(configured[2], 10);
refreshRate = Math.round(parseFloat(configured[3]));
} else if (output.modes && output.current_mode !== undefined) {
const mode = output.modes[output.current_mode];
if (mode) {
width = mode.width || 1920;
+5 -1
View File
@@ -1437,6 +1437,8 @@ window-rule {
}
function getOutputIdentifier(output, outputName) {
if (output.explicitIdentifier)
return outputName;
if (SettingsData.displayNameMode === "model" && output.make && output.model) {
const serial = output.serial || "Unknown";
return output.make + " " + output.model + " " + serial;
@@ -1490,7 +1492,9 @@ window-rule {
continue;
}
if (output.current_mode !== undefined && output.modes && output.modes[output.current_mode]) {
if (output.configured_mode) {
kdlContent += ` mode "${output.configured_mode}"\n`;
} else if (output.current_mode !== undefined && output.modes && output.modes[output.current_mode]) {
const mode = output.modes[output.current_mode];
kdlContent += ` mode "${mode.width}x${mode.height}@${(mode.refresh_rate / 1000).toFixed(3)}"\n`;
}