config: add config for using fzf/fuzzy search
This commit is contained in:
parent
ce26c8a754
commit
0097c56e09
8 changed files with 33 additions and 20 deletions
|
|
@ -175,7 +175,14 @@ All configuration options are in `~/.config/caelestia/shell.json`.
|
|||
"dragThreshold": 50,
|
||||
"enableDangerousActions": false,
|
||||
"maxShown": 8,
|
||||
"maxWallpapers": 9
|
||||
"maxWallpapers": 9,
|
||||
"useFuzzy": {
|
||||
"apps": false,
|
||||
"actions": false,
|
||||
"schemes": false,
|
||||
"variants": false,
|
||||
"wallpapers": false
|
||||
}
|
||||
},
|
||||
"lock": {
|
||||
"maxNotifs": 5
|
||||
|
|
|
|||
|
|
@ -7,6 +7,14 @@ JsonObject {
|
|||
property bool enableDangerousActions: false // Allow actions that can cause losing data, like shutdown, reboot and logout
|
||||
property int dragThreshold: 50
|
||||
|
||||
property JsonObject useFuzzy: JsonObject {
|
||||
property bool apps: false
|
||||
property bool actions: false
|
||||
property bool schemes: false
|
||||
property bool variants: false
|
||||
property bool wallpapers: false
|
||||
}
|
||||
|
||||
property JsonObject sizes: JsonObject {
|
||||
property int itemWidth: 600
|
||||
property int itemHeight: 57
|
||||
|
|
|
|||
|
|
@ -142,6 +142,7 @@ Searcher {
|
|||
}
|
||||
|
||||
list: actions.filter(a => !a.disabled)
|
||||
useFuzzy: Config.launcher.useFuzzy.actions
|
||||
|
||||
component Action: QtObject {
|
||||
required property string name
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
pragma Singleton
|
||||
|
||||
import qs.config
|
||||
import qs.utils
|
||||
import Quickshell
|
||||
import QtQuick
|
||||
|
|
@ -7,7 +8,7 @@ import QtQuick
|
|||
Searcher {
|
||||
id: root
|
||||
|
||||
function transformSearch(search: string): var {
|
||||
function transformSearch(search: string): string {
|
||||
return search.slice(`${Config.launcher.actionPrefix}variant `.length);
|
||||
}
|
||||
|
||||
|
|
@ -67,6 +68,7 @@ Searcher {
|
|||
description: "All colours are grayscale, no chroma."
|
||||
}
|
||||
]
|
||||
useFuzzy: Config.launcher.useFuzzy.variants
|
||||
|
||||
component Variant: QtObject {
|
||||
required property string variant
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
pragma Singleton
|
||||
|
||||
import qs.config
|
||||
import qs.utils
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
|
|
@ -13,6 +14,7 @@ Searcher {
|
|||
}
|
||||
|
||||
list: schemes.instances
|
||||
useFuzzy: Config.launcher.useFuzzy.schemes
|
||||
|
||||
Variants {
|
||||
id: schemes
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ PathView {
|
|||
readonly property string search: root.search.text.split(" ").slice(1).join(" ")
|
||||
|
||||
values: {
|
||||
const list = Wallpapers.fuzzyQuery(search);
|
||||
const list = Wallpapers.query(search);
|
||||
if (list.length > 1 && list.length % 2 === 0)
|
||||
list.length -= 1; // Always show odd number
|
||||
return list;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
pragma Singleton
|
||||
|
||||
import qs.config
|
||||
import qs.utils
|
||||
import Quickshell
|
||||
|
||||
|
|
@ -7,6 +8,7 @@ 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)
|
||||
|
|
|
|||
|
|
@ -1,39 +1,23 @@
|
|||
pragma Singleton
|
||||
|
||||
import "root:/utils/scripts/fuzzysort.js" as Fuzzy
|
||||
import qs.config
|
||||
import qs.utils
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import QtQuick
|
||||
|
||||
Singleton {
|
||||
Searcher {
|
||||
id: root
|
||||
|
||||
readonly property string currentNamePath: Paths.strip(`${Paths.state}/wallpaper/path.txt`)
|
||||
readonly property list<string> extensions: ["jpg", "jpeg", "png", "webp", "tif", "tiff"]
|
||||
|
||||
readonly property list<Wallpaper> list: wallpapers.instances
|
||||
property bool showPreview: false
|
||||
readonly property string current: showPreview ? previewPath : actualCurrent
|
||||
property string previewPath
|
||||
property string actualCurrent
|
||||
property bool previewColourLock
|
||||
|
||||
readonly property list<var> preppedWalls: list.map(w => ({
|
||||
name: Fuzzy.prepare(w.name),
|
||||
path: Fuzzy.prepare(w.path),
|
||||
wall: w
|
||||
}))
|
||||
|
||||
function fuzzyQuery(search: string): var {
|
||||
return Fuzzy.go(search, preppedWalls, {
|
||||
all: true,
|
||||
keys: ["name", "path"],
|
||||
scoreFn: r => r[0].score * 0.9 + r[1].score * 0.1
|
||||
}).map(r => r.obj.wall);
|
||||
}
|
||||
|
||||
function setWallpaper(path: string): void {
|
||||
actualCurrent = path;
|
||||
Quickshell.execDetached(["caelestia", "wallpaper", "-f", path]);
|
||||
|
|
@ -55,6 +39,13 @@ Singleton {
|
|||
|
||||
reloadableId: "wallpapers"
|
||||
|
||||
list: wallpapers.instances
|
||||
key: "path"
|
||||
useFuzzy: Config.launcher.useFuzzy.wallpapers
|
||||
extraOpts: useFuzzy ? ({}) : ({
|
||||
forward: false
|
||||
})
|
||||
|
||||
IpcHandler {
|
||||
target: "wallpaper"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue