diff --git a/ags/app.ts b/ags/app.ts index 7c13c19..1cc563b 100644 --- a/ags/app.ts +++ b/ags/app.ts @@ -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 = [ - new PluginApps(), - new PluginShell(), - new PluginWebSearch() + PluginApps, + PluginShell, + PluginWebSearch ]; App.start({ diff --git a/ags/window/Runner.ts b/ags/runner/Runner.ts similarity index 100% rename from ags/window/Runner.ts rename to ags/runner/Runner.ts diff --git a/ags/scripts/runner/apps.ts b/ags/runner/plugins/apps.ts similarity index 74% rename from ags/scripts/runner/apps.ts rename to ags/runner/plugins/apps.ts index ac403e1..7dc8d97 100644 --- a/ags/scripts/runner/apps.ts +++ b/ags/runner/plugins/apps.ts @@ -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; diff --git a/ags/scripts/runner/shell.ts b/ags/runner/plugins/shell.ts similarity index 54% rename from ags/scripts/runner/shell.ts rename to ags/runner/plugins/shell.ts index 8ddb70c..d36fc64 100644 --- a/ags/scripts/runner/shell.ts +++ b/ags/runner/plugins/shell.ts @@ -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; diff --git a/ags/runner/plugins/websearch.ts b/ags/runner/plugins/websearch.ts new file mode 100644 index 0000000..0f0b5b7 --- /dev/null +++ b/ags/runner/plugins/websearch.ts @@ -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; diff --git a/ags/scripts/arg-handler.ts b/ags/scripts/arg-handler.ts index 920560c..7d50c5d 100644 --- a/ags/scripts/arg-handler.ts +++ b/ags/scripts/arg-handler.ts @@ -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 = request.split(" "); diff --git a/ags/scripts/notifications.ts b/ags/scripts/notifications.ts index 4e6f1e5..4acdf41 100644 --- a/ags/scripts/notifications.ts +++ b/ags/scripts/notifications.ts @@ -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); } diff --git a/ags/scripts/runner/websearch.ts b/ags/scripts/runner/websearch.ts deleted file mode 100644 index 2283405..0000000 --- a/ags/scripts/runner/websearch.ts +++ /dev/null @@ -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); - } -} diff --git a/ags/widget/control-center/NotifHistory.ts b/ags/widget/control-center/NotifHistory.ts index 1a6ccd2..a4cd1cb 100644 --- a/ags/widget/control-center/NotifHistory.ts +++ b/ags/widget/control-center/NotifHistory.ts @@ -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) => diff --git a/ags/widget/runner/ResultWidget.ts b/ags/widget/runner/ResultWidget.ts index d2d1962..054a9c7 100644 --- a/ags/widget/runner/ResultWidget.ts +++ b/ags/widget/runner/ResultWidget.ts @@ -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 }; diff --git a/ags/window/ControlCenter.ts b/ags/window/ControlCenter.ts index 2e8e87e..8a0f0e4 100644 --- a/ags/window/ControlCenter.ts +++ b/ags/window/ControlCenter.ts @@ -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", diff --git a/ags/window/SelectWallpaper.ts b/ags/window/SelectWallpaper.ts deleted file mode 100644 index e69de29..0000000 diff --git a/ags/window/Wallpaper.ts b/ags/window/Wallpaper.ts deleted file mode 100644 index 2d0dacb..0000000 --- a/ags/window/Wallpaper.ts +++ /dev/null @@ -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 = new Variable(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 = [ - 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))