♻️ ags(runner): organize files separately from the main shell stuff
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import AstalHyprland from "gi://AstalHyprland";
|
||||
import { ResultWidget, ResultWidgetProps } from "../../widget/runner/ResultWidget";
|
||||
import AstalApps from "gi://AstalApps";
|
||||
import { getAstalApps } from "../../scripts/apps";
|
||||
import { Runner } from "../Runner";
|
||||
|
||||
export const PluginApps = {
|
||||
// Do not provide prefix, so it's always ran.
|
||||
name: "Apps",
|
||||
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;
|
||||
}
|
||||
} as Runner.Plugin;
|
||||
@@ -0,0 +1,18 @@
|
||||
import { ResultWidget, ResultWidgetProps } from "../../widget/runner/ResultWidget";
|
||||
import AstalHyprland from "gi://AstalHyprland";
|
||||
import { GLib } from "astal";
|
||||
import { Runner } from "../Runner";
|
||||
|
||||
export const PluginShell = {
|
||||
prefix: '!',
|
||||
handle: (command: string): ResultWidget => {
|
||||
const shell = GLib.getenv("SHELL") || "/usr/bin/env sh";
|
||||
|
||||
return new ResultWidget({
|
||||
onClick: () => AstalHyprland.get_default().dispatch("exec", `${shell} -c "${command}"`),
|
||||
title: `Run: \`${command}\``,
|
||||
description: shell,
|
||||
icon: "utilities-terminal-symbolic"
|
||||
} as ResultWidgetProps)
|
||||
}
|
||||
} as Runner.Plugin;
|
||||
@@ -0,0 +1,28 @@
|
||||
import AstalHyprland from "gi://AstalHyprland";
|
||||
import { ResultWidget, ResultWidgetProps } from "../../widget/runner/ResultWidget";
|
||||
import { Runner } from "../Runner";
|
||||
|
||||
const searchEngines = {
|
||||
duckduckgo: "https://duckduckgo.com/?q=",
|
||||
google: "https://google.com/search?q=",
|
||||
yahoo: "https://search.yahoo.com/search?p="
|
||||
};
|
||||
|
||||
let engine: string = searchEngines.google;
|
||||
|
||||
export const PluginWebSearch = {
|
||||
prefix: '?',
|
||||
name: "Web Search",
|
||||
|
||||
handle: (search: string): ResultWidget => {
|
||||
return new ResultWidget({
|
||||
icon: "system-search-symbolic",
|
||||
title: search || "Type your search...",
|
||||
description: `Search the Web`,
|
||||
onClick: () => AstalHyprland.get_default().dispatch(
|
||||
"exec",
|
||||
`xdg-open \"${engine + search}\"`
|
||||
)
|
||||
} as ResultWidgetProps);
|
||||
}
|
||||
} as Runner.Plugin;
|
||||
Reference in New Issue
Block a user