2022-06-10 04:49:49 +00:00
|
|
|
# SPDX-FileCopyrightText: ☭ 2022 Emery Hemingway
|
|
|
|
# SPDX-License-Identifier: Unlicense
|
|
|
|
|
|
|
|
import std/[asyncdispatch, strutils]
|
2022-06-27 15:33:02 +00:00
|
|
|
import preserves, syndicate, libnotify
|
2022-06-10 17:08:35 +00:00
|
|
|
import ./schema/notifications
|
2022-06-10 04:49:49 +00:00
|
|
|
|
2022-06-10 17:09:06 +00:00
|
|
|
proc render(a: Assertion): string =
|
|
|
|
if a.isString: a.string
|
|
|
|
else: $a
|
|
|
|
|
2022-06-10 04:49:49 +00:00
|
|
|
bootDataspace("main") do (ds: Ref; turn: var Turn):
|
|
|
|
connectStdio(ds, turn)
|
|
|
|
let nc = newNotifyClient("syndicate")
|
2022-06-10 17:09:06 +00:00
|
|
|
onPublish(turn, ds, ?Notify[Ref]) do (s: string, b: Assertion, t: int, u: Urgency):
|
|
|
|
nc.send_new_notification(s, render(b), "", t, NotificationUrgency u)
|
|
|
|
onMessage(turn, ds, ?Notify[Ref]) do (s: string, b: Assertion, t: int, u: Urgency):
|
|
|
|
nc.send_new_notification(s, render(b), "", t, NotificationUrgency u)
|
2022-06-10 04:49:49 +00:00
|
|
|
|
|
|
|
runForever()
|