From ab80d8f78681ac46e19ad97e152b7d5afe1bf999 Mon Sep 17 00:00:00 2001
From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
Date: Wed, 5 Mar 2025 19:25:49 +1100
Subject: launcher: fixes

Fix light/dark actions
Fix delay when pressing enter
---
 src/modules/launcher/actions.tsx | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

(limited to 'src/modules/launcher/actions.tsx')

diff --git a/src/modules/launcher/actions.tsx b/src/modules/launcher/actions.tsx
index c45273d..ffbd4b1 100644
--- a/src/modules/launcher/actions.tsx
+++ b/src/modules/launcher/actions.tsx
@@ -29,12 +29,6 @@ const autocomplete = (entry: Widget.Entry, action: string) => {
     entry.set_position(-1);
 };
 
-const hasMode = (mode: "light" | "dark") => {
-    const scheme = Schemes.get_default().map[Palette.get_default().scheme];
-    if (scheme.colours?.[mode]) return true;
-    return scheme.flavours?.[Palette.get_default().flavour ?? ""]?.colours?.[mode] !== undefined;
-};
-
 const actions = (mode: Variable<Mode>, entry: Widget.Entry): ActionMap => ({
     apps: {
         icon: "apps",
@@ -77,20 +71,20 @@ const actions = (mode: Variable<Mode>, entry: Widget.Entry): ActionMap => ({
         name: "Light",
         description: "Change scheme to light mode",
         action: () => {
-            execAsync(`caelestia wallpaper -T light -f ${STATE}/wallpaper/current`).catch(console.error);
+            Palette.get_default().switchMode("light");
             close();
         },
-        available: () => hasMode("light"),
+        available: () => Palette.get_default().hasMode("light"),
     },
     dark: {
         icon: "dark_mode",
         name: "Dark",
         description: "Change scheme to dark mode",
         action: () => {
-            execAsync(`caelestia wallpaper -T dark -f ${STATE}/wallpaper/current`).catch(console.error);
+            Palette.get_default().switchMode("dark");
             close();
         },
-        available: () => hasMode("dark"),
+        available: () => Palette.get_default().hasMode("dark"),
     },
     scheme: {
         icon: "palette",
-- 
cgit v1.2.3-freya

