mirror of
https://github.com/belsabbagh/dotfiles.git
synced 2026-04-11 09:36:46 +00:00
quickshell and hyprland additions
This commit is contained in:
30
.config/quickshell/nucleus-shell/services/Apps.qml
Normal file
30
.config/quickshell/nucleus-shell/services/Apps.qml
Normal file
@@ -0,0 +1,30 @@
|
||||
pragma Singleton
|
||||
|
||||
import "../modules/functions/fuzzy/fuzzysort.js" as Fuzzy
|
||||
import Quickshell
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
readonly property list<DesktopEntry> list: DesktopEntries.applications.values.filter(a => !a.noDisplay).sort((a, b) => a.name.localeCompare(b.name))
|
||||
readonly property list<var> preppedApps: list.map(a => ({
|
||||
name: Fuzzy.prepare(a.name),
|
||||
comment: Fuzzy.prepare(a.comment),
|
||||
entry: a
|
||||
}))
|
||||
|
||||
function fuzzyQuery(search: string): var { // idk why list<DesktopEntry> doesn't work
|
||||
return Fuzzy.go(search, preppedApps, {
|
||||
all: true,
|
||||
keys: ["name", "comment"],
|
||||
scoreFn: r => r[0].score > 0 ? r[0].score * 0.9 + r[1].score * 0.1 : 0
|
||||
}).map(r => r.obj.entry);
|
||||
}
|
||||
|
||||
function launch(entry: DesktopEntry): void {
|
||||
if (entry.execString.startsWith("sh -c"))
|
||||
Quickshell.execDetached(["sh", "-c", `app2unit -- ${entry.execString}`]);
|
||||
else
|
||||
Quickshell.execDetached(["sh", "-c", `app2unit -- '${entry.id}.desktop' || app2unit -- ${entry.execString}`]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user