From c2e03775dba9aedbb52c9bf1135a2290faaa21bf Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Tue, 14 Jan 2025 19:53:49 +1100 Subject: better config + notifpopups max popups Use a config file --- modules/launcher.tsx | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) (limited to 'modules/launcher.tsx') diff --git a/modules/launcher.tsx b/modules/launcher.tsx index b9ab20b..20b7c0d 100644 --- a/modules/launcher.tsx +++ b/modules/launcher.tsx @@ -3,6 +3,7 @@ import { Astal, Gtk, Widget } from "astal/gtk3"; import fuzzysort from "fuzzysort"; import type AstalApps from "gi://AstalApps"; import AstalHyprland from "gi://AstalHyprland"; +import { launcher as config } from "../config"; import { Apps } from "../services/apps"; import Math, { type HistoryItem } from "../services/math"; import { HOME } from "../utils/constants"; @@ -19,23 +20,6 @@ interface Subcommand { command: (...args: string[]) => void; } -const maxSearchResults = 15; -const fdOptions = ["-a", "-t", "f", "-E", ".git"]; - -const browser = [ - "firefox", - "waterfox", - "google-chrome", - "chromium", - "brave-browser", - "vivaldi-stable", - "vivaldi-snapshot", -]; -const terminal = ["foot", "alacritty", "kitty", "wezterm"]; -const files = ["thunar", "nemo", "nautilus"]; -const ide = ["codium", "code", "clion", "intellij-idea-ultimate-edition"]; -const music = ["spotify-adblock", "spotify", "audacious", "elisa"]; - const getIconFromMode = (mode: Mode) => { switch (mode) { case "apps": @@ -77,7 +61,7 @@ const openFileAndClose = (self: JSX.Element, path: string) => { ]).catch(console.error); }; -const PinnedApp = ({ names }: { names: string[] }) => { +const PinnedApp = (names: string[]) => { let app: Gio.DesktopAppInfo | null = null; let astalApp: AstalApps.Application | undefined; for (const name of names) { @@ -103,15 +87,7 @@ const PinnedApp = ({ names }: { names: string[] }) => { ) : null; }; -const PinnedApps = () => ( - - - - - - - -); +const PinnedApps = () => {config.pins.map(PinnedApp)}; const SearchEntry = ({ entry }: { entry: Widget.Entry }) => ( }) const appSearch = () => { const apps = Apps.fuzzy_query(entry.text); - if (apps.length > maxSearchResults) apps.length = maxSearchResults; + if (apps.length > config.maxResults) apps.length = config.maxResults; for (const app of apps) self.add(); }; @@ -289,10 +265,10 @@ const Results = ({ entry, mode }: { entry: Widget.Entry; mode: Variable }) }; const fileSearch = () => - execAsync(["fd", ...fdOptions, entry.text, HOME]) + execAsync(["fd", ...config.fdOpts, entry.text, HOME]) .then(out => { const paths = out.split("\n").filter(path => path); - if (paths.length > maxSearchResults) paths.length = maxSearchResults; + if (paths.length > config.maxResults) paths.length = config.maxResults; self.foreach(ch => ch.destroy()); for (const path of paths) self.add(); }) -- cgit v1.2.3-freya