import { Gdk, Gtk } from "ags/gtk4"; import Adw from "gi://Adw"; import AstalNotifd from "gi://AstalNotifd"; import GLib from "gi://GLib"; import Pango from "gi://Pango"; const isIcon = (icon?: string | null) => { const iconTheme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default()!); return icon && iconTheme.has_icon(icon); }; const fileExists = (path: string) => { return GLib.file_test(path, GLib.FileTest.EXISTS); }; const time = (time: number, format = "%H:%M") => { return GLib.DateTime.new_from_unix_local(time).format(format)!; }; const urgency = (n: AstalNotifd.Notification) => { const { LOW, NORMAL, CRITICAL } = AstalNotifd.Urgency; switch (n.urgency) { case LOW: return "low"; case CRITICAL: return "critical"; case NORMAL: default: return "normal"; } }; export const Notification = ({ n }: { n: AstalNotifd.Notification }) => { return ( {(n.appIcon || isIcon(n.desktopEntry)) && ( )} {n.image && fileExists(n.image) && ( )} {n.image && isIcon(n.image) && ( )} {n.actions.length > 0 && ( {n.actions.map(({ label, id }) => ( ))} )} ); };