From 8a32dd8614ada54c3f8024fc8774ed960bfa46d4 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Fri, 2 May 2025 20:05:52 +1000 Subject: launcher: fuzzy sort --- services/Apps.qml | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 services/Apps.qml (limited to 'services/Apps.qml') diff --git a/services/Apps.qml b/services/Apps.qml new file mode 100644 index 0000000..3f9fb73 --- /dev/null +++ b/services/Apps.qml @@ -0,0 +1,42 @@ +pragma Singleton + +import "fuzzysort.js" as Fuzzy +import "root:/widgets" +import "root:/config" +import Quickshell +import Quickshell.Io +import QtQuick + +Singleton { + id: root + + readonly property list list: DesktopEntries.applications.values.filter(a => !a.noDisplay).sort((a, b) => a.name.localeCompare(b.name)) + readonly property list preppedNames: list.map(a => ({ + name: Fuzzy.prepare(a.name), + entry: a + })) + + function fuzzyQuery(search: string): var { // Idk why list doesn't work + return Fuzzy.go(search, preppedNames, { + all: true, + key: "name" + }).map(r => r.obj.entry); + } + + function launch(entry: DesktopEntry): void { + launchProc.createObject(root, { + entry + }); + } + + Component { + id: launchProc + + Process { + required property DesktopEntry entry + + running: true + command: ["app2unit", "--", `${entry.id}.desktop`] + } + } +} -- cgit v1.2.3-freya