tray

package
v0.43.1 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: Apache-2.0 Imports: 30 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigDir

func ConfigDir() string

ConfigDir returns the platform-specific directory for storing configuration files. It can be overridden by the ADDER_TRAY_CONFIG_DIR environment variable.

func ConfigExists

func ConfigExists() bool

ConfigExists reports whether the configuration file exists on disk.

func ConfigPath

func ConfigPath() string

ConfigPath returns the full path to the tray configuration file.

func DefaultIconBytes added in v0.40.0

func DefaultIconBytes() []byte

DefaultIconBytes returns the raw bytes for the default gray icon.

func GetStatusIcon added in v0.40.0

func GetStatusIcon(s Status) fyne.Resource

GetStatusIcon returns a fyne.Resource with the branded logo filtered by status.

func LogDir

func LogDir() string

LogDir returns the platform-specific directory for storing log files. It can be overridden by the ADDER_TRAY_LOG_DIR environment variable.

func SaveConfig

func SaveConfig(cfg TrayConfig) error

SaveConfig writes the tray configuration to disk, creating the config directory if necessary.

Types

type App

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

App holds references to all major components of the tray application.

func NewApp

func NewApp(fyneApp fyne.App) (*App, error)

NewApp creates and initialises the tray application.

func (*App) Config added in v0.40.0

func (a *App) Config() TrayConfig

Config returns a consistent snapshot of the current tray configuration. It is safe to call from any goroutine.

func (*App) Run

func (a *App) Run()

Run configures the system tray and starts the application loop.

func (*App) Shutdown

func (a *App) Shutdown()

Shutdown gracefully tears down the tray. Ordering: close quitChan, join the producer, stop the engine, then quit fyne. Idempotent via sync.Once.

type ConnectionManager added in v0.40.0

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

ConnectionManager manages the EventClient WS connection to adder's API. It replaces the old ProcessManager — the tray no longer manages adder as a subprocess but connects to it as an API client.

func NewConnectionManager added in v0.40.0

func NewConnectionManager(opts ...ConnectionOption) *ConnectionManager

NewConnectionManager creates a ConnectionManager with the given options.

func (*ConnectionManager) Connect added in v0.40.0

func (cm *ConnectionManager) Connect() error

Connect creates and starts an EventClient that connects to adder's /events WebSocket endpoint. Returns an error if already connected.

func (*ConnectionManager) Disconnect added in v0.40.0

func (cm *ConnectionManager) Disconnect()

Disconnect stops the EventClient and cleans up.

func (*ConnectionManager) Events added in v0.40.0

func (cm *ConnectionManager) Events() <-chan event.Event

Events returns a read-only channel of events received from adder.

func (*ConnectionManager) IsConnected added in v0.40.0

func (cm *ConnectionManager) IsConnected() bool

IsConnected reports whether the EventClient is actively connected.

func (*ConnectionManager) Reconnect added in v0.40.0

func (cm *ConnectionManager) Reconnect() error

Reconnect atomically disconnects and reconnects under a single lock acquisition, so concurrent Connect/Disconnect/Reconnect callers cannot interleave and leave the manager in an inconsistent state (e.g., Reconnect reporting "already connected" because another goroutine raced in between the inner Disconnect and Connect).

func (*ConnectionManager) SetAddress added in v0.40.0

func (cm *ConnectionManager) SetAddress(address string)

SetAddress updates the adder API address for future connections.

func (*ConnectionManager) SetPort added in v0.40.0

func (cm *ConnectionManager) SetPort(port uint)

SetPort updates the adder API port for future connections.

type ConnectionOption added in v0.40.0

type ConnectionOption func(*ConnectionManager)

ConnectionOption is a functional option for ConnectionManager.

func WithConnectionAddress added in v0.40.0

func WithConnectionAddress(address string) ConnectionOption

WithConnectionAddress sets the adder API address.

func WithConnectionPort added in v0.40.0

func WithConnectionPort(port uint) ConnectionOption

WithConnectionPort sets the adder API port.

func WithConnectionStatusTracker added in v0.40.0

func WithConnectionStatusTracker(t *StatusTracker) ConnectionOption

WithConnectionStatusTracker sets a StatusTracker that the manager updates as the connection state changes.

type EventClient added in v0.39.0

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

EventClient connects to adder's /events WebSocket endpoint and delivers parsed events on a channel. It reconnects automatically with exponential backoff when the connection drops.

func NewEventClient added in v0.39.0

func NewEventClient(
	address string,
	port uint,
	opts ...EventClientOption,
) *EventClient

NewEventClient creates an EventClient that will connect to the given address and port.

func (*EventClient) Events added in v0.39.0

func (c *EventClient) Events() <-chan event.Event

Events returns a read-only channel of events received from the server.

func (*EventClient) Start added in v0.39.0

func (c *EventClient) Start() error

Start begins the background connection loop. Returns an error if already started.

func (*EventClient) Stop added in v0.39.0

func (c *EventClient) Stop()

Stop closes the connection and stops reconnection. It is safe to call multiple times or without a prior Start.

type EventClientOption added in v0.39.0

type EventClientOption func(*EventClient)

EventClientOption is a functional option for EventClient.

func WithEventStatusTracker added in v0.39.0

func WithEventStatusTracker(t *StatusTracker) EventClientOption

WithEventStatusTracker sets a StatusTracker that the client updates as its connection state changes. A nil tracker is ignored.

func WithEventTypes added in v0.39.0

func WithEventTypes(types []string) EventClientOption

WithEventTypes sets the event types to subscribe to. The types are sent as a query parameter on the WS URL for server-side filtering.

type Status added in v0.39.0

type Status int

Status represents the connection status of the tray application.

const (
	StatusStopped      Status = iota
	StatusStarting            // connecting to WS endpoint
	StatusConnected           // WS connection established
	StatusReconnecting        // WS connection lost, retrying
	StatusError               // unrecoverable error
)

func (Status) String added in v0.39.0

func (s Status) String() string

String returns a human-readable status label.

type StatusTracker added in v0.39.0

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

StatusTracker provides thread-safe status tracking with change notification. It notifies an optional observer when the status changes. Transitions are delivered to the observer by a single long-lived worker goroutine, so the observer always sees them in the order they occurred (rapid flips can no longer race).

func NewStatusTracker added in v0.39.0

func NewStatusTracker() *StatusTracker

NewStatusTracker creates a StatusTracker with initial status StatusStopped and starts its ordered-delivery worker.

func (*StatusTracker) OnChange added in v0.39.0

func (t *StatusTracker) OnChange(fn func(Status))

OnChange registers a callback that is invoked whenever the status changes. It is immediately called once with the current status synchronously. Only one observer can be registered at a time.

func (*StatusTracker) Set added in v0.39.0

func (t *StatusTracker) Set(s Status)

Set updates the status and enqueues an ordered observer notification if the status changed.

func (*StatusTracker) Status added in v0.39.0

func (t *StatusTracker) Status() Status

Status returns the current status.

type TrayConfig

type TrayConfig = setup.TrayConfig

TrayConfig is an alias for setup.TrayConfig to maintain backward compatibility.

func DefaultConfig

func DefaultConfig() TrayConfig

DefaultConfig returns a TrayConfig with sensible defaults.

func LoadConfig

func LoadConfig() (TrayConfig, error)

LoadConfig reads the tray configuration from disk. If the file does not exist, it returns the default configuration.

Directories

Path Synopsis
Package notifications implements the tray notification engine: it consumes events from the tray's ConnectionManager, evaluates them against a rule set derived from the user's setup plan, and emits notification Requests.
Package notifications implements the tray notification engine: it consumes events from the tray's ConnectionManager, evaluates them against a rule set derived from the user's setup plan, and emits notification Requests.

Jump to

Keyboard shortcuts

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