add!: add new workspace manipulation commands

This commit is contained in:
Kiana Sheibani 2025-10-07 20:30:56 -04:00
parent d202ca5cc5
commit 8f085b5c36
Signed by: toki
GPG key ID: 6CB106C25E86A9F7

View file

@ -34,26 +34,19 @@ Scope {
} }
CustomShortcut { CustomShortcut {
name: "newWorkspace" name: "newworkspace"
description: "Go to a new workspace" description: "Go to a new workspace"
onPressed: root.newWorkspace(); onPressed: root.newWorkspace();
} }
Timer {
id: newWorkspaceTimer function moveToNewWorkspace(): void {
running: false Hypr.dispatch(`hy3:movetoworkspace ${nextWorkspace()}`);
interval: Hypr.arbitraryRaceConditionDelay }
onTriggered: {
const uiState = States.getForActive(); CustomShortcut {
const workspace = Hypr.focusedWorkspace; name: "movetonewworkspace"
// Add workspace if not already added during delay description: "Move the current window to a new workspace"
let found = false; onPressed: root.moveToNewWorkspace();
for (let i = 0; i < uiState.workspaces.count; i++) {
if (uiState.workspaces.get(i).workspace.id === workspace.id)
found = true;
}
if (!found)
uiState.workspaces.append({"workspace": workspace});
}
} }
function goToWorkspace(index: int): void { function goToWorkspace(index: int): void {
@ -87,7 +80,7 @@ Scope {
} else { } else {
id = uiState.workspaces.get(index).workspace.id; id = uiState.workspaces.get(index).workspace.id;
} }
Hypr.dispatch(`movetoworkspace ${id}`); Hypr.dispatch(`hy3:movetoworkspace ${id}`);
} }
Instantiator { Instantiator {