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,
|
"dragThreshold": 50,
|
||||||
"enableDangerousActions": false,
|
"enableDangerousActions": false,
|
||||||
"maxShown": 8,
|
"maxShown": 8,
|
||||||
"maxWallpapers": 9
|
"maxWallpapers": 9,
|
||||||
|
"useFuzzy": {
|
||||||
|
"apps": false,
|
||||||
|
"actions": false,
|
||||||
|
"schemes": false,
|
||||||
|
"variants": false,
|
||||||
|
"wallpapers": false
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"lock": {
|
"lock": {
|
||||||
"maxNotifs": 5
|
"maxNotifs": 5
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,14 @@ JsonObject {
|
||||||
property bool enableDangerousActions: false // Allow actions that can cause losing data, like shutdown, reboot and logout
|
property bool enableDangerousActions: false // Allow actions that can cause losing data, like shutdown, reboot and logout
|
||||||
property int dragThreshold: 50
|
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 JsonObject sizes: JsonObject {
|
||||||
property int itemWidth: 600
|
property int itemWidth: 600
|
||||||
property int itemHeight: 57
|
property int itemHeight: 57
|
||||||
|
|
|
||||||
|
|
@ -142,6 +142,7 @@ Searcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
list: actions.filter(a => !a.disabled)
|
list: actions.filter(a => !a.disabled)
|
||||||
|
useFuzzy: Config.launcher.useFuzzy.actions
|
||||||
|
|
||||||
component Action: QtObject {
|
component Action: QtObject {
|
||||||
required property string name
|
required property string name
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
pragma Singleton
|
pragma Singleton
|
||||||
|
|
||||||
|
import qs.config
|
||||||
import qs.utils
|
import qs.utils
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
|
@ -7,7 +8,7 @@ import QtQuick
|
||||||
Searcher {
|
Searcher {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
function transformSearch(search: string): var {
|
function transformSearch(search: string): string {
|
||||||
return search.slice(`${Config.launcher.actionPrefix}variant `.length);
|
return search.slice(`${Config.launcher.actionPrefix}variant `.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,6 +68,7 @@ Searcher {
|
||||||
description: "All colours are grayscale, no chroma."
|
description: "All colours are grayscale, no chroma."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
useFuzzy: Config.launcher.useFuzzy.variants
|
||||||
|
|
||||||
component Variant: QtObject {
|
component Variant: QtObject {
|
||||||
required property string variant
|
required property string variant
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
pragma Singleton
|
pragma Singleton
|
||||||
|
|
||||||
|
import qs.config
|
||||||
import qs.utils
|
import qs.utils
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
|
|
@ -13,6 +14,7 @@ Searcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
list: schemes.instances
|
list: schemes.instances
|
||||||
|
useFuzzy: Config.launcher.useFuzzy.schemes
|
||||||
|
|
||||||
Variants {
|
Variants {
|
||||||
id: schemes
|
id: schemes
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ PathView {
|
||||||
readonly property string search: root.search.text.split(" ").slice(1).join(" ")
|
readonly property string search: root.search.text.split(" ").slice(1).join(" ")
|
||||||
|
|
||||||
values: {
|
values: {
|
||||||
const list = Wallpapers.fuzzyQuery(search);
|
const list = Wallpapers.query(search);
|
||||||
if (list.length > 1 && list.length % 2 === 0)
|
if (list.length > 1 && list.length % 2 === 0)
|
||||||
list.length -= 1; // Always show odd number
|
list.length -= 1; // Always show odd number
|
||||||
return list;
|
return list;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
pragma Singleton
|
pragma Singleton
|
||||||
|
|
||||||
|
import qs.config
|
||||||
import qs.utils
|
import qs.utils
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
|
||||||
|
|
@ -7,6 +8,7 @@ Searcher {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
list: DesktopEntries.applications.values.filter(a => !a.noDisplay).sort((a, b) => a.name.localeCompare(b.name))
|
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 {
|
function launch(entry: DesktopEntry): void {
|
||||||
if (entry.runInTerminal)
|
if (entry.runInTerminal)
|
||||||
|
|
|
||||||
|
|
@ -1,39 +1,23 @@
|
||||||
pragma Singleton
|
pragma Singleton
|
||||||
|
|
||||||
import "root:/utils/scripts/fuzzysort.js" as Fuzzy
|
|
||||||
import qs.config
|
import qs.config
|
||||||
import qs.utils
|
import qs.utils
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
|
||||||
Singleton {
|
Searcher {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
readonly property string currentNamePath: Paths.strip(`${Paths.state}/wallpaper/path.txt`)
|
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<string> extensions: ["jpg", "jpeg", "png", "webp", "tif", "tiff"]
|
||||||
|
|
||||||
readonly property list<Wallpaper> list: wallpapers.instances
|
|
||||||
property bool showPreview: false
|
property bool showPreview: false
|
||||||
readonly property string current: showPreview ? previewPath : actualCurrent
|
readonly property string current: showPreview ? previewPath : actualCurrent
|
||||||
property string previewPath
|
property string previewPath
|
||||||
property string actualCurrent
|
property string actualCurrent
|
||||||
property bool previewColourLock
|
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 {
|
function setWallpaper(path: string): void {
|
||||||
actualCurrent = path;
|
actualCurrent = path;
|
||||||
Quickshell.execDetached(["caelestia", "wallpaper", "-f", path]);
|
Quickshell.execDetached(["caelestia", "wallpaper", "-f", path]);
|
||||||
|
|
@ -55,6 +39,13 @@ Singleton {
|
||||||
|
|
||||||
reloadableId: "wallpapers"
|
reloadableId: "wallpapers"
|
||||||
|
|
||||||
|
list: wallpapers.instances
|
||||||
|
key: "path"
|
||||||
|
useFuzzy: Config.launcher.useFuzzy.wallpapers
|
||||||
|
extraOpts: useFuzzy ? ({}) : ({
|
||||||
|
forward: false
|
||||||
|
})
|
||||||
|
|
||||||
IpcHandler {
|
IpcHandler {
|
||||||
target: "wallpaper"
|
target: "wallpaper"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue