1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-06 05:25:41 -05:00

ws: add option for occupied only

This commit is contained in:
bbedward
2025-11-24 12:03:34 -05:00
parent b078e23aa1
commit 5a52edcad8
4 changed files with 64 additions and 23 deletions

View File

@@ -115,34 +115,48 @@ Item {
function getHyprlandWorkspaces() {
const workspaces = Hyprland.workspaces?.values || [];
if (workspaces.length === 0)
if (workspaces.length === 0) {
return [
{
id: 1,
name: "1"
}
];
const filtered = workspaces.filter(ws => ws.id > -1);
if (filtered.length === 0)
return [
{
id: 1,
name: "1"
}
];
if (!root.screenName || !SettingsData.workspacesPerMonitor) {
return filtered.slice().sort((a, b) => a.id - b.id);
}
const monitorWorkspaces = filtered.filter(ws => ws.monitor?.name === root.screenName);
return monitorWorkspaces.length > 0 ? monitorWorkspaces.sort((a, b) => a.id - b.id) : [
{
id: 1,
name: "1"
}
];
let filtered = workspaces.filter(ws => ws.id > -1);
if (filtered.length === 0) {
return [
{
id: 1,
name: "1"
}
];
}
if (!root.screenName || !SettingsData.workspacesPerMonitor) {
filtered = filtered.slice().sort((a, b) => a.id - b.id);
} else {
const monitorWorkspaces = filtered.filter(ws => ws.monitor?.name === root.screenName);
filtered = monitorWorkspaces.length > 0 ? monitorWorkspaces.sort((a, b) => a.id - b.id) : [
{
id: 1,
name: "1"
}
];
}
if (!SettingsData.showOccupiedWorkspacesOnly) {
return filtered;
}
const hyprlandToplevels = Array.from(Hyprland.toplevels?.values || []);
const activeWsId = root.currentWorkspace;
return filtered.filter(ws => {
if (ws.id === activeWsId)
return true;
return hyprlandToplevels.some(tl => tl.workspace?.id === ws.id);
});
}
function getHyprlandActiveWorkspace() {
@@ -287,12 +301,26 @@ Item {
return [1, 2];
}
let workspaces;
if (!root.screenName || !SettingsData.workspacesPerMonitor) {
return NiriService.getCurrentOutputWorkspaceNumbers();
workspaces = NiriService.getCurrentOutputWorkspaceNumbers();
} else {
const displayWorkspaces = NiriService.allWorkspaces.filter(ws => ws.output === root.screenName).map(ws => ws.idx + 1);
workspaces = displayWorkspaces.length > 0 ? displayWorkspaces : [1, 2];
}
const displayWorkspaces = NiriService.allWorkspaces.filter(ws => ws.output === root.screenName).map(ws => ws.idx + 1);
return displayWorkspaces.length > 0 ? displayWorkspaces : [1, 2];
if (!SettingsData.showOccupiedWorkspacesOnly) {
return workspaces;
}
return workspaces.filter(wsNum => {
const workspace = NiriService.allWorkspaces.find(w => w.idx + 1 === wsNum && w.output === root.screenName);
if (!workspace)
return false;
if (workspace.is_active)
return true;
return NiriService.windows?.some(win => win.workspace_id === workspace.id) ?? false;
});
}
function getNiriActiveWorkspace() {