diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-03-02 13:14:54 +1100 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-03-02 13:14:54 +1100 |
| commit | df3f93475ac3f04627be0918f5637cfc8cdec873 (patch) | |
| tree | 0994f49839a39a9fea2c2754ee832d9cd4f8f64c /src/modules/launcher | |
| parent | launcher: wallpaper action (diff) | |
| download | caelestia-shell-df3f93475ac3f04627be0918f5637cfc8cdec873.tar.gz caelestia-shell-df3f93475ac3f04627be0918f5637cfc8cdec873.tar.bz2 caelestia-shell-df3f93475ac3f04627be0918f5637cfc8cdec873.zip | |
launcher: light/dark actions
For switching dynamic mode
Diffstat (limited to 'src/modules/launcher')
| -rw-r--r-- | src/modules/launcher/actions.tsx | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/modules/launcher/actions.tsx b/src/modules/launcher/actions.tsx index a8c5d0a..1fc5c6b 100644 --- a/src/modules/launcher/actions.tsx +++ b/src/modules/launcher/actions.tsx @@ -1,5 +1,6 @@ import { Apps } from "@/services/apps"; import type { IPalette } from "@/services/palette"; +import Palette from "@/services/palette"; import Schemes from "@/services/schemes"; import Wallpapers from "@/services/wallpapers"; import { basename } from "@/utils/strings"; @@ -17,6 +18,7 @@ interface IAction { name: string; description: string; action: (...args: string[]) => void; + available?: () => boolean; } interface ActionMap { @@ -65,6 +67,26 @@ const actions = (mode: Variable<Mode>, entry: Widget.Entry): ActionMap => ({ entry.set_text(""); }, }, + light: { + icon: "light_mode", + name: "Light", + description: "Change dynamic scheme to light mode", + action: () => { + execAsync(`caelestia wallpaper -T light -f ${STATE}/wallpaper/current`).catch(console.error); + close(); + }, + available: () => Palette.get_default().name === "dynamic", + }, + dark: { + icon: "dark_mode", + name: "Dark", + description: "Change dynamic scheme to dark mode", + action: () => { + execAsync(`caelestia wallpaper -T dark -f ${STATE}/wallpaper/current`).catch(console.error); + close(); + }, + available: () => Palette.get_default().name === "dynamic", + }, scheme: { icon: "palette", name: "Scheme", @@ -278,7 +300,8 @@ export default class Actions extends Widget.Box implements LauncherContent { for (const { obj } of fuzzysort.go(wallpaper, Wallpapers.get_default().list, { all: true, key: "path" })) this.#content.add(<Wallpaper {...obj} />); } else { - for (const { target } of fuzzysort.go(action, this.#list, { all: true })) + const list = this.#list.filter(a => this.#map[a].available?.() ?? true); + for (const { target } of fuzzysort.go(action, list, { all: true })) this.#content.add(<Action {...this.#map[target]} args={args.slice(1)} />); } } |