perf(ags/runner): better code for runner, show results from multiple plugins, use interface to make plugins and more perfomance implementations

This commit is contained in:
retrozinndev
2025-03-12 14:11:42 -03:00
parent 0ce13b47be
commit f0cec3ff84
7 changed files with 244 additions and 220 deletions
+15 -9
View File
@@ -2,14 +2,20 @@ import AstalHyprland from "gi://AstalHyprland";
import { getAstalApps } from "../apps";
import { ResultWidget, ResultWidgetProps } from "../../widget/runner/ResultWidget";
import AstalApps from "gi://AstalApps";
import { Runner } from "../../window/Runner";
export function handleApplications(search: string): (Array<ResultWidget>|null) {
return getAstalApps().fuzzy_query(search).map((app: AstalApps.Application) =>
new ResultWidget({
title: app.get_name(),
description: app.get_description(),
icon: app.iconName,
onClick: () => AstalHyprland.get_default().dispatch("exec", app.get_executable())
} as ResultWidgetProps)
) || null;
export class PluginApps implements Runner.Plugin {
// Do not provide prefix, so it's always ran.
public readonly name = "Apps";
public handle(text: string) {
return getAstalApps().fuzzy_query(text).map((app: AstalApps.Application) =>
new ResultWidget({
title: app.get_name(),
description: app.get_description(),
icon: app.iconName,
onClick: () => AstalHyprland.get_default().dispatch("exec", app.get_executable())
} as ResultWidgetProps)
) || null;
}
}