import { GLib, register, Variable } from "astal"; import { bind, kebabify } from "astal/binding"; import { App, Astal, astalify, Gdk, Gtk, type ConstructProps } from "astal/gtk3"; import AstalHyprland from "gi://AstalHyprland"; import AstalNotifd from "gi://AstalNotifd"; import AstalTray from "gi://AstalTray"; import Players from "../services/players"; import { getAppCategoryIcon } from "../utils/icons"; import { ellipsize } from "../utils/strings"; import { osIcon } from "../utils/system"; import { setupCustomTooltip } from "../utils/widgets"; const hyprland = AstalHyprland.get_default(); const wsPerGroup = 10; const hookFocusedClientProp = ( self: any, // Ugh why is there no base Widget type prop: keyof AstalHyprland.Client, callback: (c: AstalHyprland.Client | null) => void ) => { let id: number | null = null; let lastClient: AstalHyprland.Client | null = null; self.hook(hyprland, "notify::focused-client", () => { if (id) lastClient?.disconnect(id); lastClient = hyprland.focusedClient; // Can be null id = lastClient?.connect(`notify::${kebabify(prop)}`, () => callback(lastClient)); callback(lastClient); }); self.connect("destroy", () => id && lastClient?.disconnect(id)); callback(lastClient); }; const OSIcon = () =>