mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
ws: add option for occupied only
This commit is contained in:
@@ -159,6 +159,7 @@ Singleton {
|
|||||||
property bool showWorkspaceApps: false
|
property bool showWorkspaceApps: false
|
||||||
property int maxWorkspaceIcons: 3
|
property int maxWorkspaceIcons: 3
|
||||||
property bool workspacesPerMonitor: true
|
property bool workspacesPerMonitor: true
|
||||||
|
property bool showOccupiedWorkspacesOnly: false
|
||||||
property bool dwlShowAllTags: false
|
property bool dwlShowAllTags: false
|
||||||
property var workspaceNameIcons: ({})
|
property var workspaceNameIcons: ({})
|
||||||
property bool waveProgressEnabled: true
|
property bool waveProgressEnabled: true
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ var SPEC = {
|
|||||||
showWorkspaceApps: { def: false },
|
showWorkspaceApps: { def: false },
|
||||||
maxWorkspaceIcons: { def: 3 },
|
maxWorkspaceIcons: { def: 3 },
|
||||||
workspacesPerMonitor: { def: true },
|
workspacesPerMonitor: { def: true },
|
||||||
|
showOccupiedWorkspacesOnly: { def: false },
|
||||||
dwlShowAllTags: { def: false },
|
dwlShowAllTags: { def: false },
|
||||||
workspaceNameIcons: { def: {} },
|
workspaceNameIcons: { def: {} },
|
||||||
waveProgressEnabled: { def: true },
|
waveProgressEnabled: { def: true },
|
||||||
|
|||||||
@@ -115,34 +115,48 @@ Item {
|
|||||||
|
|
||||||
function getHyprlandWorkspaces() {
|
function getHyprlandWorkspaces() {
|
||||||
const workspaces = Hyprland.workspaces?.values || [];
|
const workspaces = Hyprland.workspaces?.values || [];
|
||||||
if (workspaces.length === 0)
|
if (workspaces.length === 0) {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: "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);
|
let filtered = workspaces.filter(ws => ws.id > -1);
|
||||||
return monitorWorkspaces.length > 0 ? monitorWorkspaces.sort((a, b) => a.id - b.id) : [
|
if (filtered.length === 0) {
|
||||||
{
|
return [
|
||||||
id: 1,
|
{
|
||||||
name: "1"
|
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() {
|
function getHyprlandActiveWorkspace() {
|
||||||
@@ -287,12 +301,26 @@ Item {
|
|||||||
return [1, 2];
|
return [1, 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let workspaces;
|
||||||
if (!root.screenName || !SettingsData.workspacesPerMonitor) {
|
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);
|
if (!SettingsData.showOccupiedWorkspacesOnly) {
|
||||||
return displayWorkspaces.length > 0 ? displayWorkspaces : [1, 2];
|
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() {
|
function getNiriActiveWorkspace() {
|
||||||
|
|||||||
@@ -135,6 +135,17 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DankToggle {
|
||||||
|
width: parent.width
|
||||||
|
text: I18n.tr("Show Occupied Workspaces Only")
|
||||||
|
description: I18n.tr("Display only workspaces that contain windows")
|
||||||
|
checked: SettingsData.showOccupiedWorkspacesOnly
|
||||||
|
visible: CompositorService.isNiri || CompositorService.isHyprland
|
||||||
|
onToggled: checked => {
|
||||||
|
return SettingsData.set("showOccupiedWorkspacesOnly", checked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DankToggle {
|
DankToggle {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
text: I18n.tr("Show All Tags")
|
text: I18n.tr("Show All Tags")
|
||||||
|
|||||||
Reference in New Issue
Block a user