Documentation ¶
Overview ¶
Package notification provides an interface for sending desktop notifications and handling signals (events).
For more details see the specification: https://specifications.freedesktop.org/notification-spec/notification-spec-latest.html
Index ¶
- Constants
- Variables
- func CloseNotification(noti *Notification) error
- func GetCapabilities() (result []string, err error)
- func Init(appName, appIcon string) error
- func Notify(noti *Notification) error
- func SendNotification(summary, body, appName, appIcon string, urgency Urgency, timeout time.Duration) error
- type Notification
- func (noti *Notification) AddActionHandler(key, name string, handler func())
- func (noti *Notification) AddHint(key string, value interface{})
- func (noti *Notification) SetBody(body string)
- func (noti *Notification) SetClosedHandler(handler func(uint32))
- func (noti *Notification) SetIcon(icon string)
- func (noti *Notification) SetSummary(summary string)
- func (noti *Notification) SetTimeout(timeout time.Duration)
- func (noti *Notification) SetUrgency(urgency Urgency)
- type ServerInfo
- type Urgency
Constants ¶
const ( PackageVersion = "0.2.2" ExpiresNever = time.Duration(0) // notification never expires ExpiresDefault = time.Duration(-1000000) // depends on the server's settings ReasonExpired = 1 // the notification expired ReasonDismissed = 2 // the notification was dismissed by the user ReasonClosed = 3 // the notification was closed by a call to CloseNotification ReasonUndefined = 4 // undefined/reserved reasons )
Variables ¶
var ( AppName string AppIcon string )
Functions ¶
func CloseNotification ¶
func CloseNotification(noti *Notification) error
CloseNotification closes a notification.
func GetCapabilities ¶
GetCapabilities calls org.freedesktop.Notifications.GetCapabilities.
Types ¶
type Notification ¶
type Notification struct {
// contains filtered or unexported fields
}
Notification represents a desktop notification. A notification can be modified and updated/shown again on the screen with Notify().
func New ¶
func New(summary, body string) *Notification
New creates a new Notification. The urgency will be set to UrgencyNormal and the timeout to ExpiresDefault.
func (*Notification) AddActionHandler ¶
func (noti *Notification) AddActionHandler(key, name string, handler func())
AddActionHandler adds an action and a function to handle an org.freedesktop.Notifications.ActionInvoked signal with the specified key. Setting handler to nil will remove the function.
func (*Notification) AddHint ¶
func (noti *Notification) AddHint(key string, value interface{})
AddHint adds a hint to the notification. A hint with the key "urgency" will be ignored; use SetUrgency(). See the specification for more details.
func (*Notification) SetBody ¶
func (noti *Notification) SetBody(body string)
SetBody sets the notification's body. This is a multi-line body of text.
func (*Notification) SetClosedHandler ¶
func (noti *Notification) SetClosedHandler(handler func(uint32))
SetClosedHandler sets a function to handle the org.freedesktop.Notifications.NotificationClosed signal. This function gets one of the Reason* constants as its arguement. Setting handler to nil will remove the function.
func (*Notification) SetIcon ¶
func (noti *Notification) SetIcon(icon string)
SetIcon sets the notification's icon. If icon is an empty string AppIcon will be used.
func (*Notification) SetSummary ¶
func (noti *Notification) SetSummary(summary string)
SetSummary sets the notification's summary. This is a single line overview of the notification.
func (*Notification) SetTimeout ¶
func (noti *Notification) SetTimeout(timeout time.Duration)
SetTimeout sets the expiration timeout. This is the duration after which the notification should be closed or one of the constants ExpiresNever or ExpiresDefault.
func (*Notification) SetUrgency ¶
func (noti *Notification) SetUrgency(urgency Urgency)
SetUrgency sets the notification's urgency level. This is one of the Urgency* constants.
type ServerInfo ¶
ServerInfo represents server information.
func GetServerInformation ¶
func GetServerInformation() (*ServerInfo, error)
GetServerInformation calls org.freedesktop.Notifications.GetServerInformation.