Package notify provides an implementation of the Freedesktop Notifications Specification using the DBus API.
Display Simple Notification
ntf := notify.NewNotification("Test Notification", "Just a test")
if _, err := ntf.Show(); err != nil {
return
}
Display a Notification with Icon
ntf := notify.NewNotification("Test Notification", "Just a test")
//ntf.AppIcon = "/usr/share/icons/gnome/scalable/devices/network-wireless-symbolic.svg"
ntf.AppIcon = "network-wireless"
if _, err := ntf.Show(); err != nil {
return
}
Display a Notification with a High Priority
ntf := notify.NewNotification("Test Notification", "Just a test")
ntf.Hints = make(map[string]interface{})
ntf.Hints[notify.Urgency] = notify.UrgencyCritical
if _, err := ntf.Show(); err != nil {
return
}
Play a Sound with the Notification
ntf := notify.NewNotification("Test Notification", "Just a test")
ntf.Hints = make(map[string]interface{})
ntf.Hints[notify.HintSoundFile] = "/usr/share/sounds/freedesktop/stereo/dialog-information.oga"
if _, err := ntf.Show(); err != nil {
return
}
Close a Notification
if err = notify.CloseNotification(notification_id); err != nil {
return
}