1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-08-01 19:18:28 -04:00

workspace: fix hiding index numbers on sway

fixes #2768
This commit is contained in:
bbedward
2026-07-06 16:20:31 -04:00
parent 3e481a566b
commit 6f298d3f52
@@ -182,7 +182,7 @@ Item {
function mapWorkspace(ws) { function mapWorkspace(ws) {
return { return {
"num": ws.number, "num": ws.number,
"name": ws.name, "name": stripSwayWorkspaceNumber(ws.number, ws.name),
"focused": ws.focused, "focused": ws.focused,
"active": ws.active, "active": ws.active,
"urgent": ws.urgent, "urgent": ws.urgent,
@@ -202,6 +202,18 @@ Item {
]; ];
} }
// sway/scroll fold `<num>:<name>` into the name field (num 1 → name "1:test"); drop the redundant prefix so the index option controls it
function stripSwayWorkspaceNumber(num, name) {
if (num === undefined || num === -1)
return name;
if (typeof name !== "string")
return name;
const prefix = num + ":";
if (!name.startsWith(prefix))
return name;
return name.slice(prefix.length);
}
// Numbered workspaces first in ascending order; purely-named workspaces (sway reports num -1) after, by name // Numbered workspaces first in ascending order; purely-named workspaces (sway reports num -1) after, by name
function swayWorkspaceOrder(a, b) { function swayWorkspaceOrder(a, b) {
const keyA = a.num === -1 ? Number.MAX_SAFE_INTEGER : a.num; const keyA = a.num === -1 ? Number.MAX_SAFE_INTEGER : a.num;