Skip to content

Package notify provides an implementation of the Gnome DBus Notifications Specification.

License

Notifications You must be signed in to change notification settings

TheCreeper/go-notify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

go-notify

go-notify

Package notify provides an implementation of the Freedesktop Notifications Specification using the DBus API.

Examples

Display Simple Notification

ntf := notify.NewNotification("Test Notification", "Just a test")

if _, err := ntf.Show(); err != nil {
	return
}

Display a Notification with an Icon. Consult the Icon Naming Specification.

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 that never Expires

ntf := notify.NewNotification("Test Notification", "Just a test")
ntf.Timeout = notify.ExpiresNever

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
}