notify

package
v0.0.0-...-bedf5c0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package notify provides an API to send declarative notifications as well as playing sounds when they're sent.

Index

Constants

View Source
const MaxIconSize = 64

MaxIconSize is the maximum size of the notification icon to give to the gio.Icon.

Variables

View Source
var PlayNotificationSound = prefs.NewBool(true, prefs.PropMeta{
	Name:        "Play Notification Sound",
	Section:     "Application",
	Description: "Play a sound every time a notification pops up.",
})

PlayNotificationSound is a preference.

View Source
var ShowNotification = prefs.NewBool(true, prefs.PropMeta{
	Name:    "Show Notifications",
	Section: "Application",
	Description: "Show a notification for messages that mention the user. " +
		"No notifications are triggered if the user is focused on the window",
})

ShowNotification is a preference.

Functions

func Send

func Send(ctx context.Context, n Notification)

Send is a convenient function.

Types

type Action

type Action struct {
	ActionID string
	Argument *glib.Variant
}

Action is an action of a notification.

func ActionJSONData

func ActionJSONData(id string, data interface{}) Action

ActionJSONData creates a new Action from the given data.

type ID

type ID string

ID is a type for a notification ID. It exists so convenient hashing functions can exist. If the ID is empty, then GTK will internally generate a new one. There's no way to recall/change the notification then.

func HashID

func HashID(keys ...interface{}) ID

HashID are created from hashing the given inputs. This is useful for generating short notification IDs that are uniquely determined by the inputs.

type Icon

type Icon interface {
	// contains filtered or unexported methods
}

Icon is a type for a notification icon.

func IconName

func IconName(name string) Icon

IconName is a notification icon that follows the system icon theme.

func IconURL

func IconURL(ctx context.Context, url string, fallback Icon) Icon

IconURL creates a notification icon that is an image fetched online. The image is fetched using imgutil.GETPixbuf.

type Notification

type Notification struct {
	ID    ID
	Title string // required
	Body  string
	// Icon is the notification icon. If it's nil, then the application's icon
	// is used.
	Icon Icon
	// Action is the action to activate if the notification is clicked.
	Action Action
	// Priority is the priority of the notification.
	Priority gio.NotificationPriority
	// Sound, if true, will ring a sound. If it's an empty string, then no sound
	// is played.
	Sound Sound
}

Notification is a data structure for a notification. A GNotification object is created from this type.

func (*Notification) Send

func (n *Notification) Send(app *app.Application)

Send sends the notification to the application.

type Sound

type Sound string

Sound is a type for a notification sound.

const (
	NoSound      Sound = ""
	BellSound    Sound = sounds.Bell
	MessageSound Sound = sounds.Message
)

Known notification sound constants.

Jump to

Keyboard shortcuts

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