import { Variable } from "astal"; import { App, Astal, Gdk, Gtk, hook } from "astal/gtk4"; import AstalApps from "gi://AstalApps"; import AppList from "./modules/Apps"; const prefixes = ['=']; function hide() { App.get_window("launcher")!.hide(); } const Launcher = () => { const apps = new AstalApps.Apps(); const width = Variable(1000); const height = Variable(1000); const text = Variable(""); const visible = Variable(false); const onEnter = () => { // TODO handle custom stuff apps.fuzzy_query(text.get())?.[0].launch(); hide(); }; return { width.set(self.get_current_monitor().geometry.width); height.set(self.get_current_monitor().geometry.height); }} onKeyPressed={(self, keyval) => { if (keyval === Gdk.KEY_Escape) self.hide(); }} child={ { hook(self, App, 'window-toggled', (_, win) => { if (win.name == 'launcher') { self.set_text(''); self.grab_focus(); } }) }} onNotifyText={self => text.set(self.text)} primaryIconSensitive onActivate={onEnter} hexpand> { return !prefixes.includes(v.slice(0, 1)); })} > } > } export default Launcher;