// From astal examples import { bind, GLib } from "astal"; import { Gtk } from "astal/gtk4"; import Notifd from "gi://AstalNotifd"; import { NotificationIcon } from "./icon"; // import Pango from "gi://Pango?version=1.0" const fileExists = (path: string) => GLib.file_test(path, GLib.FileTest.EXISTS); const time = (time: number, format = "%H:%M") => GLib.DateTime.new_from_unix_local(time).format(format)!; const urgency = (n: Notifd.Notification) => { const { LOW, NORMAL, CRITICAL } = Notifd.Urgency; // match operator when? switch (n.urgency) { case LOW: return "low"; case CRITICAL: return "critical"; case NORMAL: default: return "normal"; } }; type Props = { delete: (id: number) => void; notification: Notifd.Notification; id: number; }; export default function Notification(props: Props) { const { notification: n, id: id, delete: del } = props; const { START, CENTER, END } = Gtk.Align; return ( {n.appIcon || n.desktopEntry ? ( ) : ( )} {NotificationIcon(n)} {n.get_actions().length > 0 ? ( {n.get_actions().map(({ label, id }) => ( ))} ) : ( )} ); }