♻️ ags(runner): organize files separately from the main shell stuff
This commit is contained in:
+8
-7
@@ -9,17 +9,18 @@ import { Time, timeout } from "astal/time";
|
||||
import { OSD, OSDModes, setOSDMode } from "./window/OSD";
|
||||
import { ControlCenter } from "./window/ControlCenter";
|
||||
|
||||
import { Runner } from "./window/Runner";
|
||||
import { PluginApps } from "./scripts/runner/apps";
|
||||
import { PluginShell } from "./scripts/runner/shell";
|
||||
import { PluginWebSearch } from "./scripts/runner/websearch";
|
||||
import { Runner } from "./runner/Runner";
|
||||
import { PluginApps } from "./runner/plugins/apps";
|
||||
import { PluginShell } from "./runner/plugins/shell";
|
||||
import { PluginWebSearch } from "./runner/plugins/websearch";
|
||||
|
||||
|
||||
let osdTimer: (Time|undefined);
|
||||
|
||||
const runnerPlugins: Array<Runner.Plugin> = [
|
||||
new PluginApps(),
|
||||
new PluginShell(),
|
||||
new PluginWebSearch()
|
||||
PluginApps,
|
||||
PluginShell,
|
||||
PluginWebSearch
|
||||
];
|
||||
|
||||
App.start({
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
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";
|
||||
import { getAstalApps } from "../../scripts/apps";
|
||||
import { Runner } from "../Runner";
|
||||
|
||||
export class PluginApps implements Runner.Plugin {
|
||||
export const PluginApps = {
|
||||
// Do not provide prefix, so it's always ran.
|
||||
public readonly name = "Apps";
|
||||
|
||||
public handle(text: string) {
|
||||
name: "Apps",
|
||||
handle: (text: string) => {
|
||||
return getAstalApps().fuzzy_query(text).map((app: AstalApps.Application) =>
|
||||
new ResultWidget({
|
||||
title: app.get_name(),
|
||||
@@ -18,4 +17,4 @@ export class PluginApps implements Runner.Plugin {
|
||||
} as ResultWidgetProps)
|
||||
) || null;
|
||||
}
|
||||
}
|
||||
} as Runner.Plugin;
|
||||
@@ -1,18 +1,18 @@
|
||||
import { ResultWidget, ResultWidgetProps } from "../../widget/runner/ResultWidget";
|
||||
import AstalHyprland from "gi://AstalHyprland";
|
||||
import { GLib } from "astal";
|
||||
import { Runner } from "../../window/Runner";
|
||||
import { Runner } from "../Runner";
|
||||
|
||||
export class PluginShell implements Runner.Plugin {
|
||||
public readonly prefix = '!';
|
||||
#shell = GLib.getenv("SHELL") || "/usr/bin/env sh";
|
||||
export const PluginShell = {
|
||||
prefix: '!',
|
||||
handle: (command: string): ResultWidget => {
|
||||
const shell = GLib.getenv("SHELL") || "/usr/bin/env sh";
|
||||
|
||||
public handle(command: string): ResultWidget {
|
||||
return new ResultWidget({
|
||||
onClick: () => AstalHyprland.get_default().dispatch("exec", `${this.#shell} -c "${command}"`),
|
||||
onClick: () => AstalHyprland.get_default().dispatch("exec", `${shell} -c "${command}"`),
|
||||
title: `Run: \`${command}\``,
|
||||
description: this.#shell,
|
||||
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;
|
||||
@@ -2,9 +2,9 @@ import { Gtk } from "astal/gtk3";
|
||||
import { Windows } from "../windows";
|
||||
import { restartInstance } from "./reload-handler";
|
||||
import { Wireplumber } from "./volume";
|
||||
import { startRunnerDefault } from "../window/Runner";
|
||||
import { AskPopup } from "../widget/AskPopup";
|
||||
import { execAsync } from "astal";
|
||||
import { startRunnerDefault } from "../runner/Runner";
|
||||
|
||||
export function handleArguments(request: string): any {
|
||||
const args: Array<string> = request.split(" ");
|
||||
|
||||
@@ -134,6 +134,12 @@ class Notifications extends GObject.Object {
|
||||
this.emit("notification-removed", notification.id);
|
||||
}
|
||||
|
||||
public toggleDoNotDisturb(): boolean {
|
||||
if(AstalNotifd.get_default().dontDisturb) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
connect(signal: string, callback: (...args: any[]) => void): number {
|
||||
return super.connect(signal, callback);
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
import AstalHyprland from "gi://AstalHyprland";
|
||||
import { ResultWidget, ResultWidgetProps } from "../../widget/runner/ResultWidget";
|
||||
import { Runner } from "../../window/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 class PluginWebSearch implements Runner.Plugin {
|
||||
#engineString: string;
|
||||
public readonly prefix = '?';
|
||||
public readonly name = "Web Search";
|
||||
|
||||
constructor() {
|
||||
switch(engine) {
|
||||
case searchEngines.google:
|
||||
this.#engineString = "Google";
|
||||
case searchEngines.yahoo:
|
||||
this.#engineString = "Yahoo";
|
||||
case searchEngines.duckduckgo:
|
||||
this.#engineString = "DuckDuckGo";
|
||||
default: this.#engineString = "Web";
|
||||
}
|
||||
}
|
||||
public handle(search: string): ResultWidget {
|
||||
return new ResultWidget({
|
||||
icon: "system-search-symbolic",
|
||||
title: search || "",
|
||||
description: `Search with ${this.#engineString}`,
|
||||
onClick: () => AstalHyprland.get_default().dispatch(
|
||||
"exec",
|
||||
`xdg-open \"${engine + search}\"`
|
||||
)
|
||||
} as ResultWidgetProps);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,8 @@ import { NotificationWidget } from "../Notification";
|
||||
export const NotifHistory: Gtk.Widget = new Widget.Scrollable({
|
||||
hscroll: Gtk.PolicyType.NEVER,
|
||||
vscroll: Gtk.PolicyType.AUTOMATIC,
|
||||
expand: true,
|
||||
vexpand: true,
|
||||
hexpand: true,
|
||||
child: new Widget.Box({
|
||||
className: "notifications",
|
||||
children: bind(Notifications.getDefault(), "history").as((history: Array<AstalNotifd.Notification>) =>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { register } from "astal";
|
||||
import { Gtk, Widget } from "astal/gtk3";
|
||||
import { closeRunner } from "../../window/Runner";
|
||||
import { closeRunner } from "../../runner/Runner";
|
||||
|
||||
export { ResultWidget, ResultWidgetProps };
|
||||
|
||||
|
||||
@@ -18,10 +18,11 @@ export const ControlCenter: Widget.Window = PopupWindow({
|
||||
halign: Gtk.Align.END,
|
||||
valign: Gtk.Align.START,
|
||||
visible: false,
|
||||
expand: true,
|
||||
vexpand: true,
|
||||
child: new Widget.Box({
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
expand: true,
|
||||
vexpand: true,
|
||||
children: [
|
||||
new Widget.Box({
|
||||
className: "control-center-container",
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
import { Variable } from "astal";
|
||||
import { Astal, Gdk, Gtk, Widget } from "astal/gtk3";
|
||||
import { restartInstance } from "../scripts/reload-handler";
|
||||
|
||||
const { LEFT, RIGHT, TOP, BOTTOM } = Astal.WindowAnchor;
|
||||
const wallpaper: Variable<string|undefined> = new Variable<string|undefined>(undefined);
|
||||
|
||||
const changeWallpaperButton = new Gtk.MenuItem();
|
||||
changeWallpaperButton.set_label("Change wallpaper");
|
||||
|
||||
const reloadShellButton = new Gtk.MenuItem();
|
||||
reloadShellButton.set_label("Reload Shell");
|
||||
reloadShellButton.connect("activate", (_) => restartInstance());
|
||||
|
||||
const desktopMenuButtons: Array<Gtk.MenuItem> = [
|
||||
changeWallpaperButton,
|
||||
reloadShellButton
|
||||
];
|
||||
|
||||
export const Wallpaper: Widget.Window = new Widget.Window({
|
||||
namespace: "wallpaper",
|
||||
layer: Astal.Layer.BACKGROUND,
|
||||
anchor: LEFT | RIGHT | TOP | BOTTOM,
|
||||
exclusivity: Astal.Exclusivity.IGNORE,
|
||||
keymode: Astal.Keymode.NONE,
|
||||
visible: true,
|
||||
style: new Gtk.Style(),
|
||||
css: ".wallpaper { all: unset; }",
|
||||
monitor: 0, //Needs rework for all monitors
|
||||
onButtonPressEvent: (_, event: Gdk.Event) => {
|
||||
const [ , x, y ] = event.get_coords();
|
||||
if(event.get_button()[1] === Gdk.BUTTON_SECONDARY)
|
||||
desktopMenu.popup_at_pointer(Gdk.Event.peek());
|
||||
}
|
||||
} as Widget.WindowProps);
|
||||
|
||||
const desktopMenu: Gtk.Menu = new Gtk.Menu({
|
||||
visible: true,
|
||||
monitor: Wallpaper.monitor || 0
|
||||
} as Gtk.Menu.ConstructorProps);
|
||||
|
||||
desktopMenuButtons.map((item: Gtk.MenuItem) =>
|
||||
desktopMenu.insert(item, -1))
|
||||
Reference in New Issue
Block a user