parent
f52fb9bd9e
commit
85cf0c8aed
4 changed files with 67 additions and 4 deletions
|
|
@ -282,6 +282,7 @@ All configuration options are in `~/.config/caelestia/shell.json`.
|
|||
"enableDangerousActions": false,
|
||||
"maxShown": 8,
|
||||
"maxWallpapers": 9,
|
||||
"specialPrefix": "@",
|
||||
"useFuzzy": {
|
||||
"apps": false,
|
||||
"actions": false,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ JsonObject {
|
|||
property bool enabled: true
|
||||
property int maxShown: 8
|
||||
property int maxWallpapers: 9 // Warning: even numbers look bad
|
||||
property string specialPrefix: "@"
|
||||
property string actionPrefix: ">"
|
||||
property bool enableDangerousActions: false // Allow actions that can cause losing data, like shutdown, reboot and logout
|
||||
property int dragThreshold: 50
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ StyledListView {
|
|||
name: "apps"
|
||||
|
||||
PropertyChanges {
|
||||
model.values: Apps.query(search.text)
|
||||
model.values: Apps.search(search.text)
|
||||
root.delegate: appItem
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -3,13 +3,11 @@ pragma Singleton
|
|||
import qs.config
|
||||
import qs.utils
|
||||
import Quickshell
|
||||
import QtQuick
|
||||
|
||||
Searcher {
|
||||
id: root
|
||||
|
||||
list: DesktopEntries.applications.values.filter(a => !a.noDisplay).sort((a, b) => a.name.localeCompare(b.name))
|
||||
useFuzzy: Config.launcher.useFuzzy.apps
|
||||
|
||||
function launch(entry: DesktopEntry): void {
|
||||
if (entry.runInTerminal)
|
||||
Quickshell.execDetached({
|
||||
|
|
@ -22,4 +20,67 @@ Searcher {
|
|||
workingDirectory: entry.workingDirectory
|
||||
});
|
||||
}
|
||||
|
||||
function search(search: string): list<var> {
|
||||
const prefix = Config.launcher.specialPrefix;
|
||||
|
||||
if (search.startsWith(`${prefix}i `)) {
|
||||
keys = ["id", "name"];
|
||||
weights = [0.9, 0.1];
|
||||
} else if (search.startsWith(`${prefix}c `)) {
|
||||
keys = ["categories", "name"];
|
||||
weights = [0.9, 0.1];
|
||||
} else if (search.startsWith(`${prefix}d `)) {
|
||||
keys = ["desc", "name"];
|
||||
weights = [0.9, 0.1];
|
||||
} else if (search.startsWith(`${prefix}e `)) {
|
||||
keys = ["execString", "name"];
|
||||
weights = [0.9, 0.1];
|
||||
} else if (search.startsWith(`${prefix}w `)) {
|
||||
keys = ["wmClass", "name"];
|
||||
weights = [0.9, 0.1];
|
||||
} else if (search.startsWith(`${prefix}g `)) {
|
||||
keys = ["genericName", "name"];
|
||||
weights = [0.9, 0.1];
|
||||
} else if (search.startsWith(`${prefix}k `)) {
|
||||
keys = ["keywords", "name"];
|
||||
weights = [0.9, 0.1];
|
||||
} else {
|
||||
keys = ["name"];
|
||||
weights = [1];
|
||||
|
||||
if (!search.startsWith(`${prefix}t `))
|
||||
return query(search).map(e => e.modelData);
|
||||
}
|
||||
|
||||
const results = query(search.slice(prefix.length + 2)).map(e => e.modelData);
|
||||
if (search.startsWith(`${prefix}t `))
|
||||
return results.filter(a => a.runInTerminal);
|
||||
return results;
|
||||
}
|
||||
|
||||
function selector(item: var): string {
|
||||
return keys.map(k => item[k]).join(" ");
|
||||
}
|
||||
|
||||
list: variants.instances
|
||||
useFuzzy: Config.launcher.useFuzzy.apps
|
||||
|
||||
Variants {
|
||||
id: variants
|
||||
|
||||
model: [...DesktopEntries.applications.values].sort((a, b) => a.name.localeCompare(b.name))
|
||||
|
||||
QtObject {
|
||||
required property DesktopEntry modelData
|
||||
readonly property string id: modelData.id
|
||||
readonly property string name: modelData.name
|
||||
readonly property string desc: modelData.comment
|
||||
readonly property string execString: modelData.execString
|
||||
readonly property string wmClass: modelData.startupClass
|
||||
readonly property string genericName: modelData.genericName
|
||||
readonly property string categories: modelData.categories.join(" ")
|
||||
readonly property string keywords: modelData.keywords.join(" ")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue