1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-05-14 16:22:46 -04:00

Support Hyprland lua dispatching (#2419)

This commit is contained in:
Boris
2026-05-14 19:08:07 +02:00
committed by GitHub
parent 018795125e
commit 66e38c5efe
8 changed files with 87 additions and 21 deletions
@@ -279,7 +279,7 @@ Item {
const nextIndex = direction > 0 ? Math.min(validIndex + 1, realWorkspaces.length - 1) : Math.max(validIndex - 1, 0); const nextIndex = direction > 0 ? Math.min(validIndex + 1, realWorkspaces.length - 1) : Math.max(validIndex - 1, 0);
if (nextIndex !== validIndex) { if (nextIndex !== validIndex) {
Hyprland.dispatch(`workspace ${realWorkspaces[nextIndex].id}`); HyprlandService.focusWorkspace(realWorkspaces[nextIndex].id);
} }
} else if (CompositorService.isDwl) { } else if (CompositorService.isDwl) {
const currentTag = getCurrentWorkspace(); const currentTag = getCurrentWorkspace();
@@ -580,8 +580,9 @@ Item {
NiriService.switchToWorkspace(data.id); NiriService.switchToWorkspace(data.id);
break; break;
case "hyprland": case "hyprland":
if (data.id) if (data.id) {
Hyprland.dispatch(`workspace ${data.id}`); HyprlandService.focusWorkspace(data.id);
}
break; break;
case "dwl": case "dwl":
if (data.tag !== undefined) if (data.tag !== undefined)
@@ -670,7 +671,7 @@ Item {
return; return;
} }
Hyprland.dispatch(`workspace ${realWorkspaces[nextIndex].id}`); HyprlandService.focusWorkspace(realWorkspaces[nextIndex].id);
} else if (CompositorService.isDwl) { } else if (CompositorService.isDwl) {
const realWorkspaces = getRealWorkspaces(); const realWorkspaces = getRealWorkspaces();
if (realWorkspaces.length < 2) { if (realWorkspaces.length < 2) {
@@ -1308,7 +1309,7 @@ Item {
NiriService.switchToWorkspace(modelData.id); NiriService.switchToWorkspace(modelData.id);
} }
} else if (CompositorService.isHyprland && modelData?.id) { } else if (CompositorService.isHyprland && modelData?.id) {
Hyprland.dispatch(`workspace ${modelData.id}`); HyprlandService.focusWorkspace(modelData.id);
} else if (CompositorService.isDwl && modelData?.tag !== undefined) { } else if (CompositorService.isDwl && modelData?.tag !== undefined) {
DwlService.switchToTag(root.screenName, modelData.tag); DwlService.switchToTag(root.screenName, modelData.tag);
} else if ((CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle) && modelData?.num) { } else if ((CompositorService.isSway || CompositorService.isScroll || CompositorService.isMiracle) && modelData?.num) {
@@ -1671,7 +1672,7 @@ Item {
if (!winId) if (!winId)
return; return;
if (CompositorService.isHyprland) { if (CompositorService.isHyprland) {
Hyprland.dispatch(`focuswindow address:${winId}`); HyprlandService.focusWindow(winId);
} else if (CompositorService.isNiri) { } else if (CompositorService.isNiri) {
NiriService.focusWindow(winId); NiriService.focusWindow(winId);
} }
@@ -1840,7 +1841,7 @@ Item {
if (!winId) if (!winId)
return; return;
if (CompositorService.isHyprland) { if (CompositorService.isHyprland) {
Hyprland.dispatch(`focuswindow address:${winId}`); HyprlandService.focusWindow(winId);
} else if (CompositorService.isNiri) { } else if (CompositorService.isNiri) {
NiriService.focusWindow(winId); NiriService.focusWindow(winId);
} }
+1 -1
View File
@@ -164,7 +164,7 @@ Item {
if (!specialName) if (!specialName)
return false; return false;
Hyprland.dispatch("togglespecialworkspace " + specialName); HyprlandService.toggleSpecial(specialName);
Qt.callLater(() => waylandToplevel.activate()); Qt.callLater(() => waylandToplevel.activate());
return true; return true;
} }
@@ -255,7 +255,8 @@ Scope {
} }
const targetId = thisMonitorWorkspaceIds[targetIndex]; const targetId = thisMonitorWorkspaceIds[targetIndex];
Hyprland.dispatch("workspace " + targetId);
HyprlandService.focusWorkspace(targetId);
event.accepted = true; event.accepted = true;
} }
} }
@@ -223,7 +223,7 @@ Item {
onClicked: { onClicked: {
if (root.draggingTargetWorkspace === -1) { if (root.draggingTargetWorkspace === -1) {
root.overviewOpen = false; root.overviewOpen = false;
Hyprland.dispatch(`workspace ${workspaceValue}`); HyplandService.focusWorkspace(workspaceValue)
} }
} }
} }
@@ -352,7 +352,7 @@ Item {
root.draggingTargetWorkspace = -1; root.draggingTargetWorkspace = -1;
if (targetWorkspace !== -1 && targetWorkspace !== windowData?.workspace.id) { if (targetWorkspace !== -1 && targetWorkspace !== windowData?.workspace.id) {
Hyprland.dispatch(`movetoworkspacesilent ${targetWorkspace},address:${windowData?.address}`); HyprlandService.moveToWorkspace(targetWorkspace, windowData?.address, false)
Qt.callLater(() => { Qt.callLater(() => {
Hyprland.refreshToplevels(); Hyprland.refreshToplevels();
Hyprland.refreshWorkspaces(); Hyprland.refreshWorkspaces();
@@ -372,10 +372,10 @@ Item {
return; return;
if (event.button === Qt.LeftButton) { if (event.button === Qt.LeftButton) {
root.overviewOpen = false; root.overviewOpen = false;
Hyprland.dispatch(`focuswindow address:${windowData.address}`); HyprlandService.focusWindow(windowData.address);
event.accepted = true; event.accepted = true;
} else if (event.button === Qt.MiddleButton) { } else if (event.button === Qt.MiddleButton) {
Hyprland.dispatch(`closewindow address:${windowData.address}`); HyprlandService.closeWindow(windowData.address);
event.accepted = true; event.accepted = true;
} }
} }
+2 -2
View File
@@ -682,7 +682,7 @@ Singleton {
if (isNiri) if (isNiri)
return NiriService.powerOffMonitors(); return NiriService.powerOffMonitors();
if (isHyprland) if (isHyprland)
return Hyprland.dispatch("dpms off"); return HyprlandService.dpmsOff();
if (isDwl) if (isDwl)
return _dwlPowerOffMonitors(); return _dwlPowerOffMonitors();
if (isSway || isScroll || isMiracle) { if (isSway || isScroll || isMiracle) {
@@ -701,7 +701,7 @@ Singleton {
if (isNiri) if (isNiri)
return NiriService.powerOnMonitors(); return NiriService.powerOnMonitors();
if (isHyprland) if (isHyprland)
return Hyprland.dispatch("dpms on"); return HyprlandService.dpmsOn();
if (isDwl) if (isDwl)
return _dwlPowerOnMonitors(); return _dwlPowerOnMonitors();
if (isSway || isScroll || isMiracle) { if (isSway || isScroll || isMiracle) {
+69 -5
View File
@@ -338,10 +338,74 @@ decoration {
if (!wsId) if (!wsId)
return; return;
const fullName = wsId + " " + newName; const fullName = wsId + " " + newName;
Proc.runCommand("hyprland-rename-ws", ["hyprctl", "dispatch", "renameworkspace", String(wsId), fullName], (output, exitCode) => { if (Hyprland.usingLua) {
if (exitCode !== 0) { Hyprland.dispatch(`hl.dsp.workspace.rename({workspace = "${wsId}", name = "${fullName}"})`)
log.warn("Failed to rename workspace:", output); } else {
} Proc.runCommand("hyprland-rename-ws", ["hyprctl", "dispatch", "renameworkspace", String(wsId), fullName], (output, exitCode) => {
}); if (exitCode !== 0) {
log.warn("Failed to rename workspace:", output);
}
});
}
}
function focusWorkspace(workspace) {
if (Hyprland.usingLua) {
Hyprland.dispatch(`hl.dsp.focus({workspace = "${workspace}"})`)
} else {
Hyprland.dispatch(`workspace ${workspace}`)
}
}
function focusWindow(windowAddress) {
if (Hyprland.usingLua) {
Hyprland.dispatch(`hl.dsp.focus({window = "address:${windowAddress}"})`);
} else {
Hyprland.dispatch(`focuswindow address:${windowAddress}`);
}
}
function closeWindow(windowAddress) {
if (Hyprland.usingLua) {
Hyprland.dispatch(`hl.dsp.window.close("address:${windowAddress}")`);
} else {
Hyprland.dispatch(`closewindow address:${windowAddress}`);
}
}
function moveToWorkspace(workspace, windowAddress, follow = true) {
if (Hyprland.usingLua) {
Hyprland.dispatch(`hl.dsp.window.move({workspace = "${workspace}", window="address:${windowAddress}", follow = ${follow}})`)
} else {
const dispatcher = follow ? "movetoworkspace" : "movetoworkspacesilent"
Hyprland.dispatch(`${dispatcher} ${workspace},address:${windowAddress}`);
}
}
function toggleSpecial(specialName) {
if (Hyprland.usingLua) {
Hyprland.dispatch(`hl.dsp.workspace.toggle_special(${specialName})`)
} else {
Hyprland.dispatch("togglespecialworkspace " + specialName);
}
}
function exit() {
if (Hyprland.usingLua) {
Hyprland.dispatch("hl.dsp.exit()")
} else {
Hyprland.dispatch("exit");
}
}
function dpmsOff() {
if (Hyprland.usingLua) {
Hyprland.dispatch(`hl.dsp.dpms({action = "disable"})`)
} else {
Hyprland.dispatch("dpms off");
}
}
function dpmsOn() {
if (Hyprland.usingLua) {
Hyprland.dispatch(`hl.dsp.dpms({action = "enable"})`)
} else {
Hyprland.dispatch("dpms on");
}
} }
} }
+1 -1
View File
@@ -327,7 +327,7 @@ Singleton {
return; return;
} }
Hyprland.dispatch("exit"); HyprlandService.exit();
} else { } else {
Quickshell.execDetached(["sh", "-c", SettingsData.customPowerActionLogout]); Quickshell.execDetached(["sh", "-c", SettingsData.customPowerActionLogout]);
} }