mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-29 07:52:50 -05:00
displays: add configurator (Beta)
- Position, resolution, refresh, orientation, VRR - niri, Hyprland, MangoWC - Rely on wlr-output for reading data, compositors to write output configurations - Re-organize display setting group
This commit is contained in:
@@ -1,13 +1,19 @@
|
||||
pragma Singleton
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtCore
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import qs.Common
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
readonly property string configDir: Paths.strip(StandardPaths.writableLocation(StandardPaths.ConfigLocation))
|
||||
readonly property string mangoDmsDir: configDir + "/mango/dms"
|
||||
readonly property string outputsPath: mangoDmsDir + "/outputs.conf"
|
||||
|
||||
property bool dwlAvailable: false
|
||||
property var outputs: ({})
|
||||
property var tagCount: 9
|
||||
@@ -263,4 +269,85 @@ Singleton {
|
||||
|
||||
return Array.from(visibleTags).sort((a, b) => a - b);
|
||||
}
|
||||
|
||||
function generateOutputsConfig(outputsData) {
|
||||
if (!outputsData || Object.keys(outputsData).length === 0)
|
||||
return
|
||||
|
||||
let lines = ["# Auto-generated by DMS - do not edit manually", "# VRR is global: set adaptive_sync=1 in config.conf", ""]
|
||||
|
||||
for (const outputName in outputsData) {
|
||||
const output = outputsData[outputName]
|
||||
if (!output)
|
||||
continue
|
||||
|
||||
let width = 1920
|
||||
let height = 1080
|
||||
let refreshRate = 60
|
||||
if (output.modes && output.current_mode !== undefined) {
|
||||
const mode = output.modes[output.current_mode]
|
||||
if (mode) {
|
||||
width = mode.width || 1920
|
||||
height = mode.height || 1080
|
||||
refreshRate = Math.round((mode.refresh_rate || 60000) / 1000)
|
||||
}
|
||||
}
|
||||
|
||||
const x = output.logical?.x ?? 0
|
||||
const y = output.logical?.y ?? 0
|
||||
const scale = output.logical?.scale ?? 1.0
|
||||
const transform = transformToMango(output.logical?.transform ?? "Normal")
|
||||
|
||||
const rule = [
|
||||
outputName,
|
||||
"0.55",
|
||||
"1",
|
||||
"tile",
|
||||
transform,
|
||||
scale,
|
||||
x,
|
||||
y,
|
||||
width,
|
||||
height,
|
||||
refreshRate
|
||||
].join(",")
|
||||
|
||||
lines.push("monitorrule=" + rule)
|
||||
}
|
||||
|
||||
lines.push("")
|
||||
|
||||
const content = lines.join("\n")
|
||||
|
||||
Proc.runCommand("mango-write-outputs", ["sh", "-c", `mkdir -p "${mangoDmsDir}" && cat > "${outputsPath}" << 'EOF'\n${content}EOF`], (output, exitCode) => {
|
||||
if (exitCode !== 0) {
|
||||
console.warn("DwlService: Failed to write outputs config:", output)
|
||||
return
|
||||
}
|
||||
console.info("DwlService: Generated outputs config at", outputsPath)
|
||||
if (CompositorService.isDwl)
|
||||
reloadConfig()
|
||||
})
|
||||
}
|
||||
|
||||
function reloadConfig() {
|
||||
Proc.runCommand("mango-reload", ["mmsg", "-d", "reload_config"], (output, exitCode) => {
|
||||
if (exitCode !== 0)
|
||||
console.warn("DwlService: mmsg reload_config failed:", output)
|
||||
})
|
||||
}
|
||||
|
||||
function transformToMango(transform) {
|
||||
switch (transform) {
|
||||
case "Normal": return 0
|
||||
case "90": return 1
|
||||
case "180": return 2
|
||||
case "270": return 3
|
||||
case "Flipped": return 4
|
||||
case "Flipped90": return 5
|
||||
case "Flipped180": return 6
|
||||
case "Flipped270": return 7
|
||||
default: return 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user