mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-13 14:36:32 -04:00
fix(Hyprland): Lua config for display setup writes
- Check display include status on startup from legacy to lua
This commit is contained in:
@@ -18,24 +18,32 @@ Singleton {
|
|||||||
readonly property string layoutPath: hyprDmsDir + "/layout.lua"
|
readonly property string layoutPath: hyprDmsDir + "/layout.lua"
|
||||||
readonly property string cursorPath: hyprDmsDir + "/cursor.lua"
|
readonly property string cursorPath: hyprDmsDir + "/cursor.lua"
|
||||||
readonly property string windowrulesPath: hyprDmsDir + "/windowrules.lua"
|
readonly property string windowrulesPath: hyprDmsDir + "/windowrules.lua"
|
||||||
readonly property bool luaConfigActive: CompositorService.isHyprland && Hyprland.usingLua === true
|
readonly property bool luaConfigActive: CompositorService.isHyprland && (Hyprland.usingLua === true || luaConfigDetected)
|
||||||
|
|
||||||
property int _lastGapValue: -1
|
property int _lastGapValue: -1
|
||||||
|
property bool luaConfigDetected: false
|
||||||
|
property bool luaConfigStatusReady: false
|
||||||
|
property bool luaConfigStatusLoading: false
|
||||||
|
property string luaConfigFormat: ""
|
||||||
|
|
||||||
onLuaConfigActiveChanged: {
|
onLuaConfigActiveChanged: {
|
||||||
if (luaConfigActive) {
|
if (luaConfigActive)
|
||||||
Qt.callLater(generateLayoutConfig);
|
ensureDmsLuaConfigs();
|
||||||
Qt.callLater(ensureWindowrulesConfig);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (CompositorService.isHyprland) {
|
if (CompositorService.isHyprland) {
|
||||||
Qt.callLater(generateLayoutConfig);
|
refreshLuaConfigStatus();
|
||||||
ensureWindowrulesConfig();
|
if (luaConfigActive)
|
||||||
|
ensureDmsLuaConfigs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ensureDmsLuaConfigs() {
|
||||||
|
Qt.callLater(generateLayoutConfig);
|
||||||
|
Qt.callLater(ensureWindowrulesConfig);
|
||||||
|
}
|
||||||
|
|
||||||
function ensureWindowrulesConfig() {
|
function ensureWindowrulesConfig() {
|
||||||
if (!canWriteLuaConfig("windowrules"))
|
if (!canWriteLuaConfig("windowrules"))
|
||||||
return;
|
return;
|
||||||
@@ -61,8 +69,16 @@ Singleton {
|
|||||||
Connections {
|
Connections {
|
||||||
target: CompositorService
|
target: CompositorService
|
||||||
function onIsHyprlandChanged() {
|
function onIsHyprlandChanged() {
|
||||||
if (CompositorService.isHyprland)
|
if (CompositorService.isHyprland) {
|
||||||
generateLayoutConfig();
|
refreshLuaConfigStatus();
|
||||||
|
if (luaConfigActive)
|
||||||
|
ensureDmsLuaConfigs();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
luaConfigDetected = false;
|
||||||
|
luaConfigStatusReady = false;
|
||||||
|
luaConfigStatusLoading = false;
|
||||||
|
luaConfigFormat = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,9 +92,46 @@ Singleton {
|
|||||||
return JSON.stringify(String(str ?? ""));
|
return JSON.stringify(String(str ?? ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function refreshLuaConfigStatus() {
|
||||||
|
if (!CompositorService.isHyprland) {
|
||||||
|
luaConfigDetected = false;
|
||||||
|
luaConfigStatusReady = false;
|
||||||
|
luaConfigStatusLoading = false;
|
||||||
|
luaConfigFormat = "";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (luaConfigStatusLoading)
|
||||||
|
return;
|
||||||
|
|
||||||
|
luaConfigStatusLoading = true;
|
||||||
|
Proc.runCommand("hypr-lua-config-status", ["dms", "config", "resolve-include", "hyprland", "outputs.lua"], (output, exitCode) => {
|
||||||
|
luaConfigStatusLoading = false;
|
||||||
|
luaConfigStatusReady = true;
|
||||||
|
if (exitCode !== 0) {
|
||||||
|
luaConfigDetected = false;
|
||||||
|
luaConfigFormat = "";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const status = JSON.parse(output.trim());
|
||||||
|
luaConfigFormat = status.configFormat ?? "";
|
||||||
|
luaConfigDetected = luaConfigFormat === "lua" && status.readOnly !== true;
|
||||||
|
} catch (e) {
|
||||||
|
luaConfigDetected = false;
|
||||||
|
luaConfigFormat = "";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function canWriteLuaConfig(name) {
|
function canWriteLuaConfig(name) {
|
||||||
if (luaConfigActive)
|
if (luaConfigActive)
|
||||||
return true;
|
return true;
|
||||||
|
if (CompositorService.isHyprland && !luaConfigStatusReady && !luaConfigStatusLoading)
|
||||||
|
refreshLuaConfigStatus();
|
||||||
|
if (CompositorService.isHyprland && (luaConfigStatusLoading || !luaConfigStatusReady)) {
|
||||||
|
log.debug("Deferring Hyprland", name || "config", "Lua write until config format is known");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
log.info("Skipping Hyprland", name || "config", "Lua write because the active Hyprland config is not Lua");
|
log.info("Skipping Hyprland", name || "config", "Lua write because the active Hyprland config is not Lua");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -352,7 +405,7 @@ hl.config({
|
|||||||
if (!wsId)
|
if (!wsId)
|
||||||
return;
|
return;
|
||||||
const fullName = wsId + " " + newName;
|
const fullName = wsId + " " + newName;
|
||||||
if (Hyprland.usingLua) {
|
if (luaConfigActive) {
|
||||||
Hyprland.dispatch(`hl.dsp.workspace.rename({ workspace = ${luaValue(wsId)}, name = ${luaString(fullName)} })`);
|
Hyprland.dispatch(`hl.dsp.workspace.rename({ workspace = ${luaValue(wsId)}, name = ${luaString(fullName)} })`);
|
||||||
} else {
|
} else {
|
||||||
Hyprland.dispatch(`renameworkspace ${wsId} ${fullName}`);
|
Hyprland.dispatch(`renameworkspace ${wsId} ${fullName}`);
|
||||||
@@ -360,7 +413,7 @@ hl.config({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function focusWorkspace(workspace) {
|
function focusWorkspace(workspace) {
|
||||||
if (Hyprland.usingLua) {
|
if (luaConfigActive) {
|
||||||
Hyprland.dispatch(`hl.dsp.focus({ workspace = ${luaValue(workspace)} })`);
|
Hyprland.dispatch(`hl.dsp.focus({ workspace = ${luaValue(workspace)} })`);
|
||||||
} else {
|
} else {
|
||||||
Hyprland.dispatch(`workspace ${workspace}`);
|
Hyprland.dispatch(`workspace ${workspace}`);
|
||||||
@@ -392,7 +445,7 @@ hl.config({
|
|||||||
if (!selector)
|
if (!selector)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Hyprland.usingLua) {
|
if (luaConfigActive) {
|
||||||
Hyprland.dispatch(`hl.dsp.focus({ window = ${luaString(selector)} })`);
|
Hyprland.dispatch(`hl.dsp.focus({ window = ${luaString(selector)} })`);
|
||||||
} else {
|
} else {
|
||||||
Hyprland.dispatch(`focuswindow ${selector}`);
|
Hyprland.dispatch(`focuswindow ${selector}`);
|
||||||
@@ -404,7 +457,7 @@ hl.config({
|
|||||||
if (!selector)
|
if (!selector)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Hyprland.usingLua) {
|
if (luaConfigActive) {
|
||||||
Hyprland.dispatch(`hl.dsp.window.close(${luaString(selector)})`);
|
Hyprland.dispatch(`hl.dsp.window.close(${luaString(selector)})`);
|
||||||
} else {
|
} else {
|
||||||
Hyprland.dispatch(`closewindow ${selector}`);
|
Hyprland.dispatch(`closewindow ${selector}`);
|
||||||
@@ -416,7 +469,7 @@ hl.config({
|
|||||||
if (!selector)
|
if (!selector)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Hyprland.usingLua) {
|
if (luaConfigActive) {
|
||||||
Hyprland.dispatch(`hl.dsp.window.move({ workspace = ${luaValue(workspace)}, window = ${luaString(selector)}, follow = ${follow ? "true" : "false"} })`);
|
Hyprland.dispatch(`hl.dsp.window.move({ workspace = ${luaValue(workspace)}, window = ${luaString(selector)}, follow = ${follow ? "true" : "false"} })`);
|
||||||
} else {
|
} else {
|
||||||
const dispatcher = follow ? "movetoworkspace" : "movetoworkspacesilent";
|
const dispatcher = follow ? "movetoworkspace" : "movetoworkspacesilent";
|
||||||
@@ -425,7 +478,7 @@ hl.config({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function toggleSpecial(specialName) {
|
function toggleSpecial(specialName) {
|
||||||
if (Hyprland.usingLua) {
|
if (luaConfigActive) {
|
||||||
Hyprland.dispatch(`hl.dsp.workspace.toggle_special(${luaString(specialName)})`);
|
Hyprland.dispatch(`hl.dsp.workspace.toggle_special(${luaString(specialName)})`);
|
||||||
} else {
|
} else {
|
||||||
Hyprland.dispatch("togglespecialworkspace " + specialName);
|
Hyprland.dispatch("togglespecialworkspace " + specialName);
|
||||||
@@ -433,7 +486,7 @@ hl.config({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function exit() {
|
function exit() {
|
||||||
if (Hyprland.usingLua) {
|
if (luaConfigActive) {
|
||||||
Hyprland.dispatch("hl.dsp.exit()");
|
Hyprland.dispatch("hl.dsp.exit()");
|
||||||
} else {
|
} else {
|
||||||
Hyprland.dispatch("exit");
|
Hyprland.dispatch("exit");
|
||||||
@@ -441,7 +494,7 @@ hl.config({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function dpmsOff() {
|
function dpmsOff() {
|
||||||
if (Hyprland.usingLua) {
|
if (luaConfigActive) {
|
||||||
Hyprland.dispatch(`hl.dsp.dpms({ action = "disable" })`);
|
Hyprland.dispatch(`hl.dsp.dpms({ action = "disable" })`);
|
||||||
} else {
|
} else {
|
||||||
Hyprland.dispatch("dpms off");
|
Hyprland.dispatch("dpms off");
|
||||||
@@ -449,7 +502,7 @@ hl.config({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function dpmsOn() {
|
function dpmsOn() {
|
||||||
if (Hyprland.usingLua) {
|
if (luaConfigActive) {
|
||||||
Hyprland.dispatch(`hl.dsp.dpms({ action = "enable" })`);
|
Hyprland.dispatch(`hl.dsp.dpms({ action = "enable" })`);
|
||||||
} else {
|
} else {
|
||||||
Hyprland.dispatch("dpms on");
|
Hyprland.dispatch("dpms on");
|
||||||
|
|||||||
Reference in New Issue
Block a user