syndicate_utils/src/freedesktop_notifier.nim

21 lines
719 B
Nim
Raw Normal View History

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
import ./schema/notifications
2022-06-10 04:49:49 +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")
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()