import Gtk from "gi://Gtk?version=4.0" import Gdk from "gi://Gdk?version=4.0" import Adw from "gi://Adw" import GLib from "gi://GLib" import AstalNotifd from "gi://AstalNotifd" import Pango from "gi://Pango" function isIcon(icon?: string | null) { const iconTheme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default()!) return icon && iconTheme.has_icon(icon) } function fileExists(path: string) { return GLib.file_test(path, GLib.FileTest.EXISTS) } function time(time: number, format = "%H:%M") { return GLib.DateTime.new_from_unix_local(time).format(format)! } function 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 default function Notification({ notification: n, onHoverLost, }: { notification: AstalNotifd.Notification onHoverLost: () => void }) { 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 }) => ( ))} )} ) }