notify

Types

Notification = object
  app_name*: string
  summary*, body*, icon*: string
  timeout*: int
  cptr: NotifyNotificationPtr

Procs

proc newNotification(summary, body, icon: string): Notification {...}{.raises: [], tags: [].}
Init a new notification.
var n: Notification = newNotification("Title", "Body of the notification", "icon")
n.show()

Icon values are PNG files found in places like /usr/share/icons/gnome/. Some useful ones are:

dialog-error        avatar-default  user-invisible
dialog-information  computer-fail   user-available
dialog-warning      network-error
task-due            network-idle

The Notification object returned is defaulted to 3 seconds of timeout

proc `$`(n: Notification): string {...}{.raises: [ValueError], tags: [].}
proc show(notification: Notification): bool {...}{.raises: [], tags: [].}

Show the notification in its correspondent area.

Notifications are destroyed after they are shown.

proc update(n: var Notification; summary, body, icon: string = ""): bool {...}{.raises: [],
    tags: [].}

Update the values of a notification before showing it.

Updates only the values provided, e.g.:

var n = newNotification("Title", "Body", "dialog-information")
n.update(body="New Body")
discard n.show()
# Shows a Notification with "Title", "New Body" and "dialog-information"

libnotify doesn't allow empty fields

proc timeout=(notification: var Notification; timeout: int) {...}{.inline, raises: [],
    tags: [].}
Set the Notification timeout in milliseconds.
var n = newNotification("Title", "Body", "dialog-information")
n.timeout = 500
discard n.show()