✨ ags: add ask popup, make notifications work(finally :3) and more improvements
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import AstalHyprland from "gi://AstalHyprland";
|
||||
import { getAstalApps } from "../apps";
|
||||
import { ResultWidget, ResultWidgetProps } from "../../widget/runner/ResultWidget";
|
||||
import AstalApps from "gi://AstalApps";
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { ResultWidget, ResultWidgetProps } from "../../widget/runner/ResultWidget";
|
||||
import AstalHyprland from "gi://AstalHyprland";
|
||||
import { GLib } from "astal";
|
||||
|
||||
export function handleShell(command: string): ResultWidget {
|
||||
const userShell = GLib.getenv("SHELL") || "/usr/bin/env bash";
|
||||
|
||||
return new ResultWidget({
|
||||
onClick: () => AstalHyprland.get_default().dispatch("exec", `${userShell} -c "${command}"`),
|
||||
title: `Run: \`${command}\``,
|
||||
description: userShell,
|
||||
icon: "utilities-terminal-symbolic"
|
||||
} as ResultWidgetProps);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import AstalHyprland from "gi://AstalHyprland";
|
||||
import { ResultWidget, ResultWidgetProps } from "../../widget/runner/ResultWidget";
|
||||
|
||||
export enum SearchEngine {
|
||||
GOOGLE,
|
||||
DUCKDUCKGO,
|
||||
YAHOO
|
||||
}
|
||||
|
||||
export const SearchEngineMap: Map<SearchEngine, string> = new Map([
|
||||
[ SearchEngine.DUCKDUCKGO, "https://duckduckgo.com/?q=" ],
|
||||
[ SearchEngine.GOOGLE, "https://google.com/search?q=" ],
|
||||
[ SearchEngine.YAHOO, "https://search.yahoo.com/search?p=" ]
|
||||
]);
|
||||
|
||||
let searchEngine: SearchEngine = SearchEngine.GOOGLE;
|
||||
|
||||
export function handleWebSearch(search: string): ResultWidget {
|
||||
|
||||
let engineString: string;
|
||||
|
||||
switch(searchEngine as SearchEngine) {
|
||||
case SearchEngine.GOOGLE:
|
||||
engineString = "Google";
|
||||
case SearchEngine.YAHOO:
|
||||
engineString = "Yahoo";
|
||||
case SearchEngine.DUCKDUCKGO:
|
||||
engineString = "DuckDuckGo";
|
||||
default: engineString = "Web";
|
||||
|
||||
}
|
||||
|
||||
return new ResultWidget({
|
||||
icon: "system-search-symbolic",
|
||||
title: search || "",
|
||||
description: `Search with ${engineString}`,
|
||||
onClick: () => AstalHyprland.get_default().dispatch(
|
||||
"exec",
|
||||
`xdg-open "${SearchEngineMap.get(searchEngine)! + search.replaceAll(" ", "%20")}"`
|
||||
)
|
||||
} as ResultWidgetProps);
|
||||
}
|
||||
Reference in New Issue
Block a user