notifications

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2023 License: MIT Imports: 2 Imported by: 0

README

go-notifications

Go GoDoc Go Report Card codecov

go-notifications is an implementation of the notifications dbus interface written in go (golang) for receiving notifications. Implemented and tested against version 1.2. See: https://specifications.freedesktop.org/notification-spec/1.2/.

Example

An example using this library has been implemented and is accesible at examples/example.go.

git clone git@github.com:make-42/go-notifications.git

go build examples/example.go

./example

You can then test sending notifications with:

notify-send "Notification summary" "Notification body: test test test"

Development

Versioning

This library follows the semantic versioning concept.

Commits

Commits should follow the conventional commit rules.
See: https://conventionalcommits.org.

Go Docs

Read the docs at https://pkg.go.dev/github.com/make-42/go-notifications

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Notification

type Notification struct {
	Body  NotificationBody
	Error error
}

type NotificationBody

type NotificationBody struct {
	ApplicationName   string                  // This is the optional name of the application sending the notification. This should be the application's formal name, rather than some sort of ID. An example would be "FredApp E-Mail Client," rather than "fredapp-email-client."
	ReplacesID        uint32                  // An optional ID of an existing notification that this notification is intended to replace.
	NotificationIcon  string                  // The notification icon. See Icons and Images Formats.
	Summary           string                  // This is a single line overview of the notification. For instance, "You have mail" or "A friend has come online". It should generally not be longer than 40 characters, though this is not a requirement, and server implementations should word wrap if necessary. The summary must be encoded using UTF-8.
	Body              string                  // This is a multi-line body of text. Each line is a paragraph, server implementations are free to word wrap them as they see fit. The body may contain simple markup as specified in Markup. It must be encoded using UTF-8. If the body is omitted, just the summary is displayed.
	Actions           []string                // The actions send a request message back to the notification client when invoked. This functionality may not be implemented by the notification server, conforming clients should check if it is available before using it (see the GetCapabilities message in Protocol). An implementation is free to ignore any requested by the client. As an example one possible rendering of actions would be as buttons in the notification popup. Actions are sent over as a list of pairs. Each even element in the list (starting at index 0) represents the identifier for the action. Each odd element in the list is the localized string that will be displayed to the user. The default action (usually invoked by clicking the notification) should have a key named "default". The name can be anything, though implementations are free not to display it.
	Hints             map[string]dbus.Variant // Hints are a way to provide extra data to a notification server that the server may be able to make use of. See Hints for a list of available hints.
	ExpirationTimeout int32                   // The timeout time in milliseconds since the display of the notification at which the notification should automatically close. If -1, the notification's expiration time is dependent on the notification server's settings, and may vary for the type of notification. If 0, the notification never expires.
}

See Table 1 @ https://specifications.freedesktop.org/notification-spec/notification-spec-latest.html

type NotificationReceiver

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

func NewNotificationReceiver

func NewNotificationReceiver(systemRepeatsTwice bool) (NotificationReceiver, error)

This function creates a new `NotificationReceiver` object that can then be used to receive notifications. This object has to be closed with the `Close()` method.

func (NotificationReceiver) Close

func (notificationReceiver NotificationReceiver) Close()

This method closes the `NotificationReceiver` object.

func (NotificationReceiver) GetBlocking

func (notificationReceiver NotificationReceiver) GetBlocking() Notification

This method blocks until a notification is received and returns the subsequent `Notification` object.

func (NotificationReceiver) GetChannel

func (notificationReceiver NotificationReceiver) GetChannel() chan Notification

This method returns a channel that receives `Notification` objects.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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