From 935a87a8ed257642349ce8604fb8d59f251e9564 Mon Sep 17 00:00:00 2001 From: lucy Date: Mon, 26 Oct 2026 11:13:24 +0100 Subject: [PATCH] sort ws by number --- modules/bar/Ws.qml | 22 +++++++++++++++++++++- settings/settings.json | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/modules/bar/Ws.qml b/modules/bar/Ws.qml index 6ea257b..d8bc20f 100644 --- a/modules/bar/Ws.qml +++ b/modules/bar/Ws.qml @@ -10,13 +10,33 @@ BarComponent { id: root required property ShellScreen barScreen implicitWidth: wsLayout.implicitWidth + 16 + readonly property var sortedWindowsets: { + const projection = WindowManager.screenProjection(root.barScreen) + const sets = projection ? (projection.windowsets ?? []) : [] + + const numericName = ws => { + const name = ws ? String(ws.name ?? "") : "" + return name !== "" && Number.isFinite(Number(name)) ? Number(name) : NaN + } + + return Array.from(sets).sort((a, b) => { + const na = numericName(a) + const nb = numericName(b) + if (!isNaN(na) && !isNaN(nb)) + return na - nb + + const byName = String(a?.name ?? "").localeCompare(String(b?.name ?? ""), undefined, { numeric: true }) + return byName !== 0 ? byName : (a?.id ?? 0) - (b?.id ?? 0) + }) + } + RowLayout { id: wsLayout anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter spacing: 4 Repeater { - model: WindowManager.screenProjection(root.barScreen).windowsets + model: root.sortedWindowsets delegate: Rectangle { id: wsContainer required property var modelData diff --git a/settings/settings.json b/settings/settings.json index 4b8cb84..a6df2ce 100644 --- a/settings/settings.json +++ b/settings/settings.json @@ -14,6 +14,6 @@ }, "wallpaper": { "wallDir": "/home/lucy/.walls/", - "wallpaper": "/home/lucy/.walls/walkingcastle.png" + "wallpaper": "/home/lucy/.walls/lain_blue.jpg" } }