mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-08 14:38:30 -04:00
@@ -402,6 +402,17 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert monitors.json config entry → internal outputsData map
|
// 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) {
|
function generateOutputsDataFromConfig(configEntry) {
|
||||||
const result = {};
|
const result = {};
|
||||||
const cfgOutputs = configEntry.outputs || {};
|
const cfgOutputs = configEntry.outputs || {};
|
||||||
@@ -410,20 +421,20 @@ Singleton {
|
|||||||
// Find matching live output to get modes list
|
// Find matching live output to get modes list
|
||||||
let liveOutput = null;
|
let liveOutput = null;
|
||||||
for (const name in outputs) {
|
for (const name in outputs) {
|
||||||
if (getOutputIdentifier(outputs[name], name) === outputId || name === outputId) {
|
if (profileKeyMatchesOutput(outputId, outputs[name], name)) {
|
||||||
liveOutput = outputs[name];
|
liveOutput = outputs[name];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const liveModes = liveOutput?.modes || [];
|
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);
|
const s = m.width + "x" + m.height + "@" + (m.refresh_rate / 1000).toFixed(3);
|
||||||
return s === cfg.mode;
|
return s === cfg.mode;
|
||||||
});
|
});
|
||||||
if (currentMode < 0 && liveModes.length > 0)
|
|
||||||
currentMode = 0;
|
|
||||||
const entry = {
|
const entry = {
|
||||||
"name": outputId,
|
"name": outputId,
|
||||||
|
"explicitIdentifier": true,
|
||||||
|
"configured_mode": cfg.mode || "",
|
||||||
"make": liveOutput?.make || "",
|
"make": liveOutput?.make || "",
|
||||||
"model": liveOutput?.model || "",
|
"model": liveOutput?.model || "",
|
||||||
"serial": liveOutput?.serial || "",
|
"serial": liveOutput?.serial || "",
|
||||||
@@ -1846,7 +1857,7 @@ Singleton {
|
|||||||
|
|
||||||
function getHyprlandOutputIdentifier(output, outputName) {
|
function getHyprlandOutputIdentifier(output, outputName) {
|
||||||
if (SettingsData.displayNameMode === "model" && output?.make && output?.model)
|
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;
|
return outputName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -105,8 +105,10 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getOutputIdentifier(output, outputName) {
|
function getOutputIdentifier(output, outputName) {
|
||||||
|
if (output.explicitIdentifier)
|
||||||
|
return outputName;
|
||||||
if (SettingsData.displayNameMode === "model" && output.make && output.model)
|
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;
|
return outputName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,8 +196,8 @@ Singleton {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let resolution = "preferred";
|
let resolution = output.configured_mode || "preferred";
|
||||||
if (output.modes && output.current_mode !== undefined) {
|
if (!output.configured_mode && output.modes && output.current_mode !== undefined) {
|
||||||
const mode = output.modes[output.current_mode];
|
const mode = output.modes[output.current_mode];
|
||||||
if (mode)
|
if (mode)
|
||||||
resolution = mode.width + "x" + mode.height + "@" + (mode.refresh_rate / 1000).toFixed(3);
|
resolution = mode.width + "x" + mode.height + "@" + (mode.refresh_rate / 1000).toFixed(3);
|
||||||
|
|||||||
@@ -542,7 +542,12 @@ Singleton {
|
|||||||
let width = 1920;
|
let width = 1920;
|
||||||
let height = 1080;
|
let height = 1080;
|
||||||
let refreshRate = 60;
|
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];
|
const mode = output.modes[output.current_mode];
|
||||||
if (mode) {
|
if (mode) {
|
||||||
width = mode.width || 1920;
|
width = mode.width || 1920;
|
||||||
|
|||||||
@@ -1437,6 +1437,8 @@ window-rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getOutputIdentifier(output, outputName) {
|
function getOutputIdentifier(output, outputName) {
|
||||||
|
if (output.explicitIdentifier)
|
||||||
|
return outputName;
|
||||||
if (SettingsData.displayNameMode === "model" && output.make && output.model) {
|
if (SettingsData.displayNameMode === "model" && output.make && output.model) {
|
||||||
const serial = output.serial || "Unknown";
|
const serial = output.serial || "Unknown";
|
||||||
return output.make + " " + output.model + " " + serial;
|
return output.make + " " + output.model + " " + serial;
|
||||||
@@ -1490,7 +1492,9 @@ window-rule {
|
|||||||
continue;
|
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];
|
const mode = output.modes[output.current_mode];
|
||||||
kdlContent += ` mode "${mode.width}x${mode.height}@${(mode.refresh_rate / 1000).toFixed(3)}"\n`;
|
kdlContent += ` mode "${mode.width}x${mode.height}@${(mode.refresh_rate / 1000).toFixed(3)}"\n`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user