diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-03-04 23:47:30 +1100 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-03-05 11:41:20 +1100 |
| commit | 3e10adce741b0d5797a7337400e226431211b9d0 (patch) | |
| tree | f3e09a48fb1f80a41e34c7cf1bf6fe5bf3a951fe /src/modules | |
| parent | launcher: math mode (diff) | |
| download | caelestia-shell-3e10adce741b0d5797a7337400e226431211b9d0.tar.gz caelestia-shell-3e10adce741b0d5797a7337400e226431211b9d0.tar.bz2 caelestia-shell-3e10adce741b0d5797a7337400e226431211b9d0.zip | |
launcher: fix random wallpaper + add random scheme
Also allow mixed case for scheme and wallpaper suboptions
Diffstat (limited to 'src/modules')
| -rw-r--r-- | src/modules/launcher/actions.tsx | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/src/modules/launcher/actions.tsx b/src/modules/launcher/actions.tsx index 1fc5c6b..f1e66d4 100644 --- a/src/modules/launcher/actions.tsx +++ b/src/modules/launcher/actions.tsx @@ -91,26 +91,13 @@ const actions = (mode: Variable<Mode>, entry: Widget.Entry): ActionMap => ({ icon: "palette", name: "Scheme", description: "Change the current colour scheme", - action: (...args) => { - // If no args, autocomplete cmd - if (args.length === 0) return autocomplete(entry, "scheme"); - - execAsync(`caelestia scheme ${args[0]}`).catch(console.error); - close(); - }, + action: () => autocomplete(entry, "scheme"), }, wallpaper: { icon: "image", name: "Wallpaper", description: "Change the current wallpaper", - action: (...args) => { - // If no args, autocomplete cmd - if (args.length === 0) return autocomplete(entry, "wallpaper"); - - if (args[0] === "random") execAsync("caelestia wallpaper").catch(console.error); - else execAsync(`caelestia wallpaper -f ${args[0]}`).catch(console.error); - close(); - }, + action: () => autocomplete(entry, "wallpaper"), }, todo: { icon: "checklist", @@ -289,7 +276,7 @@ export default class Actions extends Widget.Box implements LauncherContent { updateContent(search: string): void { this.#content.foreach(c => c.destroy()); const args = search.split(" "); - const action = args[0].slice(1); + const action = args[0].slice(1).toLowerCase(); if (action === "scheme") { const scheme = args[1] ?? ""; @@ -306,7 +293,15 @@ export default class Actions extends Widget.Box implements LauncherContent { } } - handleActivate(): void { + handleActivate(search: string): void { + 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); + close(); + } + this.#content.get_child_at_index(0)?.get_child()?.activate(); } } |