diff --git a/quickshell/Modules/Settings/DisplayConfig/DisplayConfigState.qml b/quickshell/Modules/Settings/DisplayConfig/DisplayConfigState.qml index 7d5b40944..64d66a649 100644 --- a/quickshell/Modules/Settings/DisplayConfig/DisplayConfigState.qml +++ b/quickshell/Modules/Settings/DisplayConfig/DisplayConfigState.qml @@ -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; } diff --git a/quickshell/Services/HyprlandService.qml b/quickshell/Services/HyprlandService.qml index 8a6aa3319..4184badb0 100644 --- a/quickshell/Services/HyprlandService.qml +++ b/quickshell/Services/HyprlandService.qml @@ -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); diff --git a/quickshell/Services/MangoService.qml b/quickshell/Services/MangoService.qml index 9fbfd6b1f..3696611e3 100644 --- a/quickshell/Services/MangoService.qml +++ b/quickshell/Services/MangoService.qml @@ -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; diff --git a/quickshell/Services/NiriService.qml b/quickshell/Services/NiriService.qml index de1f87472..e81a49141 100644 --- a/quickshell/Services/NiriService.qml +++ b/quickshell/Services/NiriService.qml @@ -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`; }