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

feat(Hyprland): Introduce Lua support for Hyprland configurations

- Note: We do not convert your existing conf configs to lua. This update only reflects DMS defaults state
- Updated README.md to reflect changes
- Updated Keyboard shortcut support
This commit is contained in:
purian23
2026-05-18 13:06:58 -04:00
parent 8dd891f93a
commit 0b55bf5dac
48 changed files with 3756 additions and 1057 deletions
+58 -8
View File
@@ -7,6 +7,7 @@ import Quickshell
import Quickshell.Io
import qs.Common
import qs.Services
import "../Common/ConfigIncludeResolve.js" as ConfigIncludeResolve
import "../Common/KeybindActions.js" as Actions
Singleton {
@@ -82,6 +83,7 @@ Singleton {
case "niri":
return compositorConfigDir + "/dms/binds.kdl";
case "hyprland":
return compositorConfigDir + "/dms/binds.lua";
case "mangowc":
return compositorConfigDir + "/dms/binds.conf";
default:
@@ -93,7 +95,7 @@ Singleton {
case "niri":
return compositorConfigDir + "/config.kdl";
case "hyprland":
return compositorConfigDir + "/hyprland.conf";
return compositorConfigDir + "/hyprland.lua";
case "mangowc":
return compositorConfigDir + "/config.conf";
default:
@@ -247,8 +249,8 @@ Singleton {
root.lastError = "";
root.dmsBindsIncluded = true;
root.dmsBindsFixed();
const bindsFile = root.currentProvider === "niri" ? "dms/binds.kdl" : "dms/binds.conf";
ToastService.showInfo(I18n.tr("Binds include added"), I18n.tr("%1 is now included in config").arg(bindsFile), "", "keybinds");
const bindsRel = root.currentProvider === "niri" ? "dms/binds.kdl" : root.currentProvider === "hyprland" ? "dms/binds.lua" : "dms/binds.conf";
ToastService.showInfo(I18n.tr("Binds include added"), I18n.tr("%1 is now included in config").arg(bindsRel), "", "keybinds");
Qt.callLater(root.forceReload);
}
}
@@ -262,13 +264,36 @@ Singleton {
let script;
switch (currentProvider) {
case "niri":
script = `mkdir -p "${compositorConfigDir}/dms" && touch "${compositorConfigDir}/dms/binds.kdl" && cp "${mainConfigPath}" "${backupPath}" && echo 'include "dms/binds.kdl"' >> "${mainConfigPath}"`;
script = ConfigIncludeResolve.buildRepairScript({
configFile: mainConfigPath,
backupFile: backupPath,
fragmentFile: compositorConfigDir + "/dms/binds.kdl",
grepPattern: 'include.*"dms/binds.kdl"',
includeLine: 'include "dms/binds.kdl"'
});
break;
case "hyprland":
script = `mkdir -p "${compositorConfigDir}/dms" && touch "${compositorConfigDir}/dms/binds.conf" && cp "${mainConfigPath}" "${backupPath}" && echo 'source = ./dms/binds.conf' >> "${mainConfigPath}"`;
script = ConfigIncludeResolve.buildRepairScript({
configFile: mainConfigPath,
backupFile: backupPath,
fragmentFiles: [compositorConfigDir + "/dms/binds.lua", compositorConfigDir + "/dms/binds-user.lua"],
includes: [{
grepPattern: "dms.binds",
includeLine: "require(\"dms.binds\")"
}, {
grepPattern: "dms.binds-user",
includeLine: "require(\"dms.binds-user\")"
}]
});
break;
case "mangowc":
script = `mkdir -p "${compositorConfigDir}/dms" && touch "${compositorConfigDir}/dms/binds.conf" && cp "${mainConfigPath}" "${backupPath}" && echo 'source = ./dms/binds.conf' >> "${mainConfigPath}"`;
script = ConfigIncludeResolve.buildRepairScript({
configFile: mainConfigPath,
backupFile: backupPath,
fragmentFile: compositorConfigDir + "/dms/binds.conf",
grepPattern: "source.*dms/binds.conf",
includeLine: "source = ./dms/binds.conf"
});
break;
default:
fixing = false;
@@ -321,6 +346,7 @@ Singleton {
"statusMessage": status.statusMessage ?? ""
};
}
_maybeWarnHyprlandLegacyConf();
if (!_rawData?.binds) {
_allBinds = {};
@@ -365,10 +391,13 @@ Singleton {
for (var i = 0; i < binds.length; i++) {
const bind = binds[i];
const action = bind.action || "";
const sourceStr = bind.source || "config";
const keyData = {
"key": bind.key || "",
"source": bind.source || "config",
"isOverride": bind.source === "dms",
"source": sourceStr,
"isOverride": sourceStr === "dms",
"isDMSManaged": sourceStr === "dms" || sourceStr === "dms-default",
"hasDefault": bind.hasDefault === true,
"cooldownMs": bind.cooldownMs || 0,
"flags": bind.flags || "",
"allowWhenLocked": bind.allowWhenLocked || false,
@@ -456,6 +485,19 @@ Singleton {
_pendingSavedKey = bindData.key;
}
property bool _hyprlandLegacyWarnShown: false
function _maybeWarnHyprlandLegacyConf() {
if (_hyprlandLegacyWarnShown)
return;
if (currentProvider !== "hyprland")
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");
}
function removeBind(key) {
if (!key)
return;
@@ -464,6 +506,14 @@ Singleton {
bindRemoved(key);
}
function resetBind(key) {
if (!key)
return;
removeProcess.command = ["dms", "keybinds", "reset", currentProvider, key];
removeProcess.running = true;
bindRemoved(key);
}
function isDmsAction(action) {
return Actions.isDmsAction(action);
}