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

Add option to only show apps in the current workspace in the running apps widget

niri only currently - but should be simple enough to add support for
others
This commit is contained in:
Gonen Gazit
2025-08-26 21:53:54 +03:00
parent 6e75e2b06c
commit baea0ecc92
5 changed files with 98 additions and 7 deletions

View File

@@ -451,11 +451,7 @@ Singleton {
function sortToplevels(toplevels) {
if (!toplevels || toplevels.length === 0 || !CompositorService.isNiri || windows.length === 0) {
return [...toplevels]
}
function getToplevelToNiriMap(toplevels){
// Create a map to match toplevels to niri windows
// We'll match by appId and title since toplevels don't have numeric IDs
var toplevelToNiriMap = {}
@@ -488,6 +484,15 @@ Singleton {
}
}
}
return toplevelToNiriMap
}
function sortToplevels(toplevels) {
if (!toplevels || toplevels.length === 0 || !CompositorService.isNiri || windows.length === 0) {
return [...toplevels]
}
const toplevelToNiriMap = getToplevelToNiriMap(toplevels)
// Sort toplevels using niri's ordering
return [...toplevels].sort((a, b) => {
@@ -511,4 +516,17 @@ Singleton {
})
}
function filterCurrentWorkspace(toplevels, screenName){
const toplevelToNiriMap = getToplevelToNiriMap(toplevels)
var currentWorkspaceId = null
for (var i = 0; i < NiriService.allWorkspaces.length; i++) {
var ws = NiriService.allWorkspaces[i]
if (ws.output === screenName && ws.is_active){
currentWorkspaceId = ws.id
}
}
return toplevels.filter((t, idx) => toplevelToNiriMap[idx] && toplevelToNiriMap[idx].niriWindow.workspace_id == currentWorkspaceId)
}
}