1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-06-08 04:09:15 -04:00

refactor(Hyprland): Update Lua migration and keybind writes

- emit native hl.dsp.* dispatchers for generated Lua keybinds
- keep legacy hyprland.conf installs read-only but preserved until dms setup migration
This commit is contained in:
purian23
2026-05-30 23:07:06 -04:00
parent 389fffaf64
commit a265625851
20 changed files with 1056 additions and 109 deletions
+26
View File
@@ -18,9 +18,17 @@ Singleton {
readonly property string layoutPath: hyprDmsDir + "/layout.lua"
readonly property string cursorPath: hyprDmsDir + "/cursor.lua"
readonly property string windowrulesPath: hyprDmsDir + "/windowrules.lua"
readonly property bool luaConfigActive: CompositorService.isHyprland && Hyprland.usingLua === true
property int _lastGapValue: -1
onLuaConfigActiveChanged: {
if (luaConfigActive) {
Qt.callLater(generateLayoutConfig);
Qt.callLater(ensureWindowrulesConfig);
}
}
Component.onCompleted: {
if (CompositorService.isHyprland) {
Qt.callLater(generateLayoutConfig);
@@ -29,6 +37,8 @@ Singleton {
}
function ensureWindowrulesConfig() {
if (!canWriteLuaConfig("windowrules"))
return;
Proc.runCommand("hypr-ensure-windowrules", ["sh", "-c", `mkdir -p "${hyprDmsDir}" && [ ! -f "${windowrulesPath}" ] && touch "${windowrulesPath}" || true`], (output, exitCode) => {
if (exitCode !== 0)
log.warn("Failed to ensure windowrules.lua:", output);
@@ -66,6 +76,13 @@ Singleton {
return JSON.stringify(String(str ?? ""));
}
function canWriteLuaConfig(name) {
if (luaConfigActive)
return true;
log.info("Skipping Hyprland", name || "config", "Lua write because the active Hyprland config is not Lua");
return false;
}
function forceFlagValue(value) {
if (value === true)
return 1;
@@ -75,6 +92,11 @@ Singleton {
}
function generateOutputsConfig(outputsData, hyprlandSettings, callback) {
if (!canWriteLuaConfig("outputs")) {
if (callback)
callback(false);
return;
}
if (!outputsData || Object.keys(outputsData).length === 0) {
if (callback)
callback(false);
@@ -172,6 +194,8 @@ Singleton {
function generateLayoutConfig() {
if (!CompositorService.isHyprland)
return;
if (!canWriteLuaConfig("layout"))
return;
const defaultRadius = typeof SettingsData !== "undefined" ? SettingsData.cornerRadius : 12;
const defaultGaps = typeof SettingsData !== "undefined" ? Math.max(4, (SettingsData.barConfigs[0]?.spacing ?? 4)) : 4;
@@ -254,6 +278,8 @@ hl.config({
function generateCursorConfig() {
if (!CompositorService.isHyprland)
return;
if (!canWriteLuaConfig("cursor"))
return;
const settings = typeof SettingsData !== "undefined" ? SettingsData.cursorSettings : null;
if (!settings) {
+33 -3
View File
@@ -52,7 +52,9 @@ Singleton {
"bindsAfterDms": 0,
"effective": true,
"overriddenBy": 0,
"statusMessage": ""
"statusMessage": "",
"configFormat": "",
"readOnly": false
})
property var _rawData: null
@@ -102,6 +104,7 @@ Singleton {
return "";
}
}
readonly property bool readOnly: currentProvider === "hyprland" && dmsStatus.readOnly === true
readonly property var actionTypes: Actions.getActionTypes()
readonly property var dmsActions: getDmsActions()
@@ -258,6 +261,10 @@ Singleton {
function fixDmsBindsInclude() {
if (fixing || dmsBindsIncluded || !compositorConfigDir)
return;
if (readOnly) {
showHyprlandReadOnlyWarning();
return;
}
fixing = true;
const timestamp = Math.floor(Date.now() / 1000);
const backupPath = `${mainConfigPath}.dmsbackup${timestamp}`;
@@ -343,7 +350,9 @@ Singleton {
"bindsAfterDms": status.bindsAfterDms ?? 0,
"effective": status.effective ?? true,
"overriddenBy": status.overriddenBy ?? 0,
"statusMessage": status.statusMessage ?? ""
"statusMessage": status.statusMessage ?? "",
"configFormat": status.configFormat ?? "",
"readOnly": status.readOnly === true
};
}
_maybeWarnHyprlandLegacyConf();
@@ -482,6 +491,10 @@ Singleton {
}
function saveBind(originalKey, bindData) {
if (readOnly) {
showHyprlandReadOnlyWarning();
return;
}
if (!bindData.key || !Actions.isValidAction(bindData.action))
return;
saving = true;
@@ -510,13 +523,26 @@ Singleton {
return;
if (currentProvider !== "hyprland")
return;
if (readOnly) {
_hyprlandLegacyWarnShown = true;
showHyprlandReadOnlyWarning();
return;
}
if (!dmsStatus.exists || dmsStatus.included)
return;
_hyprlandLegacyWarnShown = true;
ToastService.showWarning(I18n.tr("Hyprland config still uses hyprlang"), I18n.tr("DMS Settings now writes Lua. Edits won't apply until you migrate."), "dms setup", "hyprland-migration");
ToastService.showWarning(I18n.tr("Hyprland config include missing"), I18n.tr("DMS Settings writes Lua keybinds. Add the DMS include so edits apply."), "dms setup", "hyprland-migration");
}
function showHyprlandReadOnlyWarning() {
ToastService.showWarning(I18n.tr("Hyprland conf mode"), I18n.tr("This install is still using hyprland.conf. Run dms setup to migrate before editing shortcuts in Settings."), "dms setup", "hyprland-migration");
}
function removeBind(key) {
if (readOnly) {
showHyprlandReadOnlyWarning();
return;
}
if (!key)
return;
removeProcess.command = ["dms", "keybinds", "remove", currentProvider, key];
@@ -525,6 +551,10 @@ Singleton {
}
function resetBind(key) {
if (readOnly) {
showHyprlandReadOnlyWarning();
return;
}
if (!key)
return;
removeProcess.command = ["dms", "keybinds", "reset", currentProvider, key];