From dddc7382a59009b6a0e7e2322559efd9087c5acf Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sat, 15 Mar 2025 13:53:53 +1100 Subject: launcher: wallpaper random by category --- src/modules/launcher/actions.tsx | 47 +++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 10 deletions(-) (limited to 'src/modules/launcher') diff --git a/src/modules/launcher/actions.tsx b/src/modules/launcher/actions.tsx index 05005a4..4ebabfb 100644 --- a/src/modules/launcher/actions.tsx +++ b/src/modules/launcher/actions.tsx @@ -1,7 +1,7 @@ import { Apps } from "@/services/apps"; import Palette from "@/services/palette"; import Schemes, { type Colours } from "@/services/schemes"; -import Wallpapers from "@/services/wallpapers"; +import Wallpapers, { type ICategory, type IWallpaper } from "@/services/wallpapers"; import { basename } from "@/utils/strings"; import { notify } from "@/utils/system"; import { setupCustomTooltip, type FlowBox } from "@/utils/widgets"; @@ -285,7 +285,7 @@ const Scheme = ({ scheme, name, colours }: { scheme?: string; name: string; colo ); }; -const Wallpaper = ({ path, thumbnail }: { path: string; thumbnail?: string }) => ( +const Wallpaper = ({ path, thumbnail }: IWallpaper) => ( + +); + @register() export default class Actions extends Widget.Box implements LauncherContent { #map: ActionMap; @@ -348,9 +374,12 @@ export default class Actions extends Widget.Box implements LauncherContent { } } } else if (action === "wallpaper") { - const wallpaper = args[1] ?? ""; - for (const { obj } of fuzzysort.go(wallpaper, Wallpapers.get_default().list, { all: true, key: "path" })) - this.#content.add(); + const random = args[1].toLowerCase() === "random"; + const term = (random ? args[2] : args[1]) ?? ""; + const list = random ? Wallpapers.get_default().categories : Wallpapers.get_default().list; + + for (const { obj } of fuzzysort.go(term, list, { all: true, key: "path" })) + this.#content.add(random ? : ); } else { const list = this.#list.filter( a => this.#map[a].available?.() ?? !config.disabledActions.get().includes(a) @@ -364,11 +393,9 @@ export default class Actions extends Widget.Box implements LauncherContent { const args = search.split(" "); const action = args[0].slice(1).toLowerCase(); - if ((action === "scheme" || action === "wallpaper") && args[1].toLowerCase() === "random") { - execAsync(`caelestia ${action}`).catch(console.error); + if (action === "scheme" && args[1].toLowerCase() === "random") { + execAsync(`caelestia scheme`).catch(console.error); close(); - } - - this.#content.get_child_at_index(0)?.get_child()?.activate(); + } else this.#content.get_child_at_index(0)?.get_child()?.activate(); } } -- cgit v1.2.3-freya