finished workspaces

This commit is contained in:
2026-06-23 15:33:25 +01:00
parent 26767ae588
commit 2b49211315
4 changed files with 222 additions and 6 deletions

View File

@@ -6,6 +6,15 @@ import Quickshell.Hyprland
Singleton {
id: root
function activateNextFreeWorkspace() {
let nextFree = getNextFreeWorkspace();
activateWorkspaceById(nextFree);
}
function activateWorkspaceById(id) {
Hyprland.dispatch(`hl.dsp.focus({workspace = ${id}})`);
}
function getAllNumberedWorkspaces() {
let allWorkspaces = Hyprland.workspaces.values;
let filteredWorkspaces = [];
@@ -20,6 +29,39 @@ Singleton {
return filteredWorkspaces;
}
function getNextFreeWorkspace() {
let workspaceList = getAllNumberedWorkspaces();
if (workspaceList[workspaceList.length - 1].id == workspaceList.length) {
return workspaceList.length + 1;
} else {
let prevWorkspace = 0;
for (let workspace in workspaceList) {
let currentWorkspace = workspaceList[workspace];
if (currentWorkspace.id != (prevWorkspace + 1)) {
return currentWorkspace.id - 1;
} else {
prevWorkspace = currentWorkspace.id;
}
}
}
}
function getNumberOfWorkspaces(monitor) {
let workspaceList = getWorkspacesForMonitor(monitor);
return workspaceList.length;
}
function getWorkspaceState(workspace) {
if (workspace.focused == true) {
return "focused";
} else if (workspace.active == true) {
return "active";
} else {
return "inactive";
}
}
function getWorkspacesForMonitor(monitor) {
let allWorkspaces = getAllNumberedWorkspaces();
let monitorWorkspaces = [];
@@ -27,7 +69,6 @@ Singleton {
for (let workspace in allWorkspaces) {
let currentWorkspace = allWorkspaces[workspace];
if (currentWorkspace.monitor == monitor) {
console.log(currentWorkspace.id);
if (currentWorkspace) {
monitorWorkspaces.push(currentWorkspace);
}