From 2293da9789c0bddecd230b1b5794a6e790bd8588 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Fri, 24 Jan 2025 19:38:16 +1100 Subject: launcher: windows mode Also files mode icons --- config.ts | 7 ++ scss/launcher.scss | 1 + src/modules/launcher.tsx | 238 +++++++++++++++++++++++++++++++++++++++++++---- src/utils/types.ts | 32 +++++++ 4 files changed, 262 insertions(+), 16 deletions(-) create mode 100644 src/utils/types.ts diff --git a/config.ts b/config.ts index 6845c5f..3ea635a 100644 --- a/config.ts +++ b/config.ts @@ -16,6 +16,13 @@ export const launcher = { ["codium", "code", "clion", "intellij-idea-ultimate-edition"], ["spotify-adblock", "spotify", "audacious", "elisa"], ], + windows: { + // Weights for fuzzysort + title: 1, + class: 1, + initialTitle: 0.5, + initialClass: 0.5, + }, }; export const notifpopups = { diff --git a/scss/launcher.scss b/scss/launcher.scss index f0df755..8ffd51c 100644 --- a/scss/launcher.scss +++ b/scss/launcher.scss @@ -29,6 +29,7 @@ @include launcher(apps, scheme.$sapphire); @include launcher(files, scheme.$peach); @include launcher(math, scheme.$green); + @include launcher(windows, scheme.$teal); .search-bar { margin-bottom: lib.s(5); diff --git a/src/modules/launcher.tsx b/src/modules/launcher.tsx index 0e72224..b588e3a 100644 --- a/src/modules/launcher.tsx +++ b/src/modules/launcher.tsx @@ -1,17 +1,18 @@ import { bind, execAsync, Gio, GLib, register, timeout, Variable } from "astal"; -import { Astal, Gtk, Widget } from "astal/gtk3"; +import { App, 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 MathService, { type HistoryItem } from "../services/math"; import { getAppCategoryIcon } from "../utils/icons"; import { launch } from "../utils/system"; +import type { Client } from "../utils/types"; import { MenuItem, setupCustomTooltip } from "../utils/widgets"; import PopupWindow from "../widgets/popupwindow"; -type Mode = "apps" | "files" | "math"; +type Mode = "apps" | "files" | "math" | "windows"; interface Subcommand { icon: string; @@ -28,6 +29,8 @@ const getIconFromMode = (mode: Mode) => { return "folder"; case "math": return "calculate"; + case "windows": + return "select_window_2"; } }; @@ -39,6 +42,8 @@ const getEmptyTextFromMode = (mode: Mode) => { return GLib.find_program_in_path("fd") === null ? "File search requires `fd`" : "No files found"; case "math": return "Type an expression"; + case "windows": + return "No windows found"; } }; @@ -133,14 +138,16 @@ const Result = ({ materialIcon, label, sublabel, + tooltip, onClicked, onSecondaryClick, onDestroy, }: { - icon?: string; + icon?: string | Gio.Icon | null; materialIcon?: string; label: string; sublabel?: string; + tooltip?: string; onClicked: (self: Widget.Button) => void; onSecondaryClick?: (self: Widget.Button) => void; onDestroy?: () => void; @@ -148,16 +155,19 @@ const Result = ({