import { Variable, Gio } from "astal"; import { App, Astal, Gdk, Gtk, hook } from "astal/gtk4"; import AstalApps from "gi://AstalApps"; import { Picture } from "../common"; export const WINDOW_NAME = "app-launcher"; const apps = new AstalApps.Apps(); const text = Variable(""); const hide = () => { App.get_window(WINDOW_NAME)?.set_visible(false); }; const AppButton = ({ app }: { app: AstalApps.Application }) => { return ( ); }; const AppList = () => { const appList = text((text) => apps.fuzzy_query(text)); return ( {appList.as((list) => list.map((app) => ))} ); }; const AppSearch = () => { const onEnter = () => { apps.fuzzy_query(text.get())?.[0].launch(); hide(); }; return ( text.set(self.text)} onActivate={onEnter} setup={(self) => { hook(self, App, "window-toggled", (_, win) => { const winName = win.name; const visible = win.visible; if (winName == WINDOW_NAME && visible) { text.set(""); self.set_text(""); self.grab_focus(); } }); }} /> ); }; export const AppLauncher = (gdkmonitor: Gdk.Monitor) => { return ( { if (keyval === Gdk.KEY_Escape) { App.toggle_window(WINDOW_NAME); } }} > ); };