notification

package
v1.7.3-0...-caeaf44 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Send

func Send(data NotificationData) error

Send is a convenience function for sending notifications. If a default notifier has been set via SetDefaultNotifier(), it will be used (enabling action callbacks like OpenURL and OpenPath). Otherwise, a temporary notifier with default settings is created.

func SetDefaultNotifier

func SetDefaultNotifier(n *Notifier)

SetDefaultNotifier sets the package-level notifier used by Send(). This allows the application to configure action callbacks (OpenURL, OpenPath) that will be used for all notifications sent via Send().

Types

type NotificationData

type NotificationData struct {
	Title      string `json:"title" mapstructure:"title"`
	Message    string `json:"message" mapstructure:"message"`
	Icon       string `json:"icon,omitempty" mapstructure:"icon"`
	Duration   int    `json:"duration,omitempty" mapstructure:"duration"`     // Duration in milliseconds
	ActionURL  string `json:"actionUrl,omitempty" mapstructure:"actionUrl"`   // URL to open when notification is clicked
	ActionPath string `json:"actionPath,omitempty" mapstructure:"actionPath"` // File/folder path to open when notification is clicked
	Sound      string `json:"sound,omitempty" mapstructure:"sound"`           // Path to sound file to play
}

NotificationData represents the data needed for a notification

type Notifier

type Notifier struct {
	// contains filtered or unexported fields
}

Notifier handles desktop notifications

func GetDefaultNotifier

func GetDefaultNotifier() *Notifier

GetDefaultNotifier returns the package-level notifier, or nil if not set.

func NewNotifier

func NewNotifier(opts NotifierOptions) (*Notifier, error)

NewNotifier creates a new notification handler

func (*Notifier) Close

func (n *Notifier) Close() error

Close closes the notifier and releases resources

func (*Notifier) Send

func (n *Notifier) Send(data NotificationData) (uint32, error)

Send sends a notification and returns the notification ID

type NotifierOptions

type NotifierOptions struct {
	// AppName is shown in notifications (defaults to "System Bridge")
	AppName string
	// SoundFile is the default sound file path (optional)
	SoundFile string
	// OpenURL is called when a notification with ActionURL is clicked
	OpenURL func(string) error
	// OpenPath is called when a notification with ActionPath is clicked
	OpenPath func(string) error
}

NotifierOptions contains optional configuration for creating a Notifier

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL