freedesktop

package
v0.0.0-...-75f61f4 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 8 Imported by: 1

Documentation

Overview

Package freedesktop implements the Desktop Notifications Specification version 1.2.

See https://developer.gnome.org/notification-spec/ for details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewNotifier

func NewNotifier(name string) (notify.Notifier, error)

NewNotifier returns a new Notifier.

Register supports following icon types:

  • string
  • image.Image

Register accepts following keys and value types:

  • freedesktop:actions map[string]string
  • freedesktop:hints map[string]interface{}
  • freedesktop:timeout int32

Types

type ActionInvoked

type ActionInvoked struct {
	ID  uint32
	Key string
}

ActionInvoked represents an ActionInvoked signal.

type Client

type Client struct {
	NotificationClosed chan NotificationClosed
	ActionInvoked      chan ActionInvoked
	// contains filtered or unexported fields
}

Client is a notification client.

func New

func New() (*Client, error)

New returns a new Client connected to the session bus.

func (*Client) Close

func (c *Client) Close() error

Close closes the D-Bus connection.

func (*Client) CloseNotification

func (c *Client) CloseNotification(id uint32) error

CloseNotification closes and removes the notification of the specified id.

func (*Client) GetCapabilities

func (c *Client) GetCapabilities() (caps []string, err error)

GetCapabilities retrieves capabilities that the server implements.

See https://developer.gnome.org/notification-spec/#command-get-capabilities for available capabilities.

func (*Client) GetServerInformation

func (c *Client) GetServerInformation() (si ServerInfo, err error)

GetServerInformation retrieves the information of the server.

func (*Client) Notify

func (c *Client) Notify(n *Notification) (id uint32, err error)

Notify sends a notification to the server.

type ImageData

type ImageData struct {
	Width         int32
	Height        int32
	Stride        int32
	Alpha         bool
	BitsPerSample int32
	NumChannels   int32
	Data          []byte
}

ImageData represents a raw image data structure of signature (iiibiiay).

See https://developer.gnome.org/notification-spec/#icons-and-images for details.

func NewImageData

func NewImageData(img image.Image) (*ImageData, error)

NewImageData returns a new raw image data structure from the specified img.

type Notification

type Notification struct {
	Name    string                 // Application Name
	ID      uint32                 // Replaces ID
	Icon    string                 // Notification Icon
	Summary string                 // Summary
	Body    string                 // Body
	Actions []string               // Actions
	Hints   map[string]interface{} // Hints
	Timeout int32                  // Expiration Timeout
}

Notification represents a notification.

See https://developer.gnome.org/notification-spec/#basic-design for details.

func (*Notification) Action

func (n *Notification) Action(key, label string)

Action adds (or replaces) the specified action to the Notification.

func (*Notification) Hint

func (n *Notification) Hint(name string, value interface{}) error

Hint adds (or replaces) the specified hint to the Notification.

See https://developer.gnome.org/notification-spec/#hints for available hints.

type NotificationClosed

type NotificationClosed struct {
	ID     uint32
	Reason Reason
}

NotificationClosed represents a NotificationClosed signal.

type Reason

type Reason uint32

Reason represents a reason of the NotificationClosed signal.

const (
	ReasonExpired Reason = 1 + iota
	ReasonDismissed
	ReasonClosed
	ReasonUndefined
)

List of reasons for the NotificationClosed signal.

func (Reason) String

func (r Reason) String() string

type ServerInfo

type ServerInfo struct {
	Name        string
	Vendor      string
	Version     string
	SpecVersion string
}

ServerInfo represents the information of a server.

Jump to

Keyboard shortcuts

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