diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-07-19 14:49:47 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-07-19 14:49:47 +1000 |
| commit | 0097c56e09b8501cabdfac2e15d536f121446cc4 (patch) | |
| tree | 8388d0b2bca7212c3ab4ba1f617b36bb6a05721f | |
| parent | feat: fzf-like search instead of fuzzy (diff) | |
| download | caelestia-shell-0097c56e09b8501cabdfac2e15d536f121446cc4.tar.gz caelestia-shell-0097c56e09b8501cabdfac2e15d536f121446cc4.tar.bz2 caelestia-shell-0097c56e09b8501cabdfac2e15d536f121446cc4.zip | |
config: add config for using fzf/fuzzy search
| -rw-r--r-- | README.md | 9 | ||||
| -rw-r--r-- | config/LauncherConfig.qml | 8 | ||||
| -rw-r--r-- | modules/launcher/Actions.qml | 1 | ||||
| -rw-r--r-- | modules/launcher/M3Variants.qml | 4 | ||||
| -rw-r--r-- | modules/launcher/Schemes.qml | 2 | ||||
| -rw-r--r-- | modules/launcher/WallpaperList.qml | 2 | ||||
| -rw-r--r-- | services/Apps.qml | 2 | ||||
| -rw-r--r-- | services/Wallpapers.qml | 25 |
8 files changed, 33 insertions, 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 diff --git a/config/LauncherConfig.qml b/config/LauncherConfig.qml index 081d068..2cd42a1 100644 --- a/config/LauncherConfig.qml +++ b/config/LauncherConfig.qml @@ -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 diff --git a/modules/launcher/Actions.qml b/modules/launcher/Actions.qml index 0e658f0..afe831b 100644 --- a/modules/launcher/Actions.qml +++ b/modules/launcher/Actions.qml @@ -142,6 +142,7 @@ Searcher { } list: actions.filter(a => !a.disabled) + useFuzzy: Config.launcher.useFuzzy.actions component Action: QtObject { required property string name diff --git a/modules/launcher/M3Variants.qml b/modules/launcher/M3Variants.qml index 4312ff1..69bd805 100644 --- a/modules/launcher/M3Variants.qml +++ b/modules/launcher/M3Variants.qml @@ -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 diff --git a/modules/launcher/Schemes.qml b/modules/launcher/Schemes.qml index 2be8558..068dcbd 100644 --- a/modules/launcher/Schemes.qml +++ b/modules/launcher/Schemes.qml @@ -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 diff --git a/modules/launcher/WallpaperList.qml b/modules/launcher/WallpaperList.qml index 78cc146..f59dd29 100644 --- a/modules/launcher/WallpaperList.qml +++ b/modules/launcher/WallpaperList.qml @@ -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; diff --git a/services/Apps.qml b/services/Apps.qml index b8ec38e..e2addcd 100644 --- a/services/Apps.qml +++ b/services/Apps.qml @@ -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) diff --git a/services/Wallpapers.qml b/services/Wallpapers.qml index b81a891..b9c408a 100644 --- a/services/Wallpapers.qml +++ b/services/Wallpapers.qml @@ -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" |