Documentation
¶
Overview ¶
Package notify implements Go bindings for libnotify to create, send, and update OS level notifications. It does not shell out to `notify-send` so it can update existing notifications as well as create new ones.
This package requires Cgo and the libnotify (libnotify-dev) shared library to be installed.
On Ubuntu or Debian you can install with: sudo apt-get install libnotify-dev
Index ¶
- func SetDebugLogger(logger Logger)
- func SetErrorLogger(logger Logger)
- type Logger
- type Notification
- func (n *Notification) AddAction(actionId, label string, onActionCallback NotificationActionCallback) error
- func (n *Notification) Close() error
- func (n *Notification) SetTimeout(timeout Timeout) error
- func (n *Notification) SetUrgency(urgency Urgency) error
- func (n *Notification) Show() error
- func (n *Notification) Update(summary, body, icon string) error
- type NotificationActionCallback
- type Notifier
- type Timeout
- type Urgency
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetDebugLogger ¶ added in v0.6.0
func SetDebugLogger(logger Logger)
SetDebugLogger set the Logger that will receive debug logging.
func SetErrorLogger ¶ added in v0.6.0
func SetErrorLogger(logger Logger)
SetErrorLogger set the Logger that will receive error logging.
Types ¶
type Logger ¶ added in v0.6.0
type Logger func(...interface{})
Logger logs relevant information about the state of the application. Idea stolen from https://old.reddit.com/r/golang/comments/4eh1c3/logging_in_libraries_whats_the_best_practice/
type Notification ¶
type Notification struct {
// contains filtered or unexported fields
}
Notification represents an instance of a single notification
func (*Notification) AddAction ¶ added in v0.6.0
func (n *Notification) AddAction(actionId, label string, onActionCallback NotificationActionCallback) error
AddAction adds an action to a notification. `label` is what appears on the notification button. `onActionCallback` is the function invoked when the action is triggered. Multiple actions can be added to the same notification.
func (*Notification) Close ¶
func (n *Notification) Close() error
Close removes the notification from the OS
func (*Notification) SetTimeout ¶ added in v0.5.0
func (n *Notification) SetTimeout(timeout Timeout) error
SetTimeout sets the timeout of the notification in milliseconds. To use the default expiration time, pass notify.DefaultTimeout. To set the notification to never expire, pass notify.InfinityTimeout.
func (*Notification) SetUrgency ¶
func (n *Notification) SetUrgency(urgency Urgency) error
SetUrgency sets the notification urgency (Low, Normal, Critical)
func (*Notification) Show ¶
func (n *Notification) Show() error
Show sends the notification to the OS for displaying
func (*Notification) Update ¶
func (n *Notification) Update(summary, body, icon string) error
Update an existing notification with new information
type NotificationActionCallback ¶ added in v0.6.0
type NotificationActionCallback func()
NotificationActionCallback is called when an action on a notification is invoked
type Notifier ¶
type Notifier struct {
// contains filtered or unexported fields
}
Notifier is an instance of an application sending notifications
func NewNotifier ¶
NewNotifier initializes a new application to send notifications. It's required to call this function first.
func (*Notifier) ApplicationName ¶
ApplicationName returns the current application's initialized name
func (*Notifier) NewNotification ¶
func (n *Notifier) NewNotification(summary, body, icon string) (*Notification, error)
NewNotification creates a new notification
type Timeout ¶ added in v0.5.0
type Timeout int64
Timeout represent the time in milliseconds after which a a notification will be closed. Should be > 0. Two special values exist, the default timeout (denoted by -1) and the infinity timeout (denoted by 0).
const ( // DefaultTimeout is the default expiration time on a notification. DefaultTimeout Timeout = -1 // InfinityTimeout set the notification to never expire. It stays open // until closed by the calling API or the user. InfinityTimeout = 0 )