import app from "ags/gtk3/app" import { Astal, Gtk } from "ags/gtk3" import { createPoll } from "ags/time" import { For } from "ags" import { sh, shell } from "../lib/utils" export const NOTIFICATION_WINDOW = "notification-center" type Notification = { id: number appName: string summary: string body: string } function parseNotifications(stdout: string): Notification[] { try { const parsed = JSON.parse(stdout) const group = parsed?.data?.[0] ?? [] return group.map((item: any) => ({ id: item.id?.value ?? 0, appName: item["app-name"]?.value ?? "", summary: item.summary?.value ?? "", body: item.body?.value ?? "", })) } catch { return [] } } const notifications = createPoll( [], 1000, shell("makoctl list -j 2>/dev/null || echo '{}'"), (stdout) => parseNotifications(stdout), ) const doNotDisturb = createPoll( false, 1000, shell("makoctl mode 2>/dev/null"), (stdout) => stdout.split("\n").includes("do-not-disturb"), ) const dismiss = (id: number) => sh(`makoctl dismiss -n ${id}`) const clearAll = () => sh("makoctl dismiss -a") const toggleDoNotDisturb = () => sh("makoctl mode -t do-not-disturb") function NotificationItem({ item }: { item: Notification }) { return ( ) } export default function NotificationCenter() { const { TOP, RIGHT } = Astal.WindowAnchor const hasNotifications = notifications.as((list) => list.length > 0) const isEmpty = notifications.as((list) => list.length === 0) return ( item.id}> {(item: Notification) => } ) }