Help us shape the future of Go! Take the 2026 Go Developer Survey

traymenu

package
v1.38.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const ActionUpdate = "update"

ActionUpdate opens a terminal running `lerd update` rather than a command.

Variables

This section is empty.

Functions

func ActionMessage

func ActionMessage(args []string, err error, stderr string) (title, body string, show bool)

ActionMessage is the notification for a finished menu action: what was done, or what failed with the last line lerd printed. Opening the dashboard shows itself, so only its failure is reported.

Types

type Getter

type Getter func(path string) (io.ReadCloser, error)

Getter fetches one lerd API path, over HTTP for a tray or in process for lerd-ui.

type Menu struct {
	Running          bool       `json:"running"`
	HighContrastIcon bool       `json:"high_contrast_icon"`
	LatestVersion    string     `json:"latest_version,omitempty"`
	Items            []MenuItem `json:"items"`
}

Menu is the tray menu resolved from lerd's state, for clients that draw it themselves: the desktop app, or a status bar module. Labels carry no glyphs.

func BuildMenu

func BuildMenu(snap *Snapshot, opts MenuOptions) Menu

BuildMenu resolves the menu for snap. A client keeps its tray for as long as it runs, so the native tray's "Turn off system tray" has no place here.

func ReadMenu

func ReadMenu(get Getter, settings func() Settings, opts MenuOptions) Menu

ReadMenu reads lerd's state through get and settings and resolves the menu.

func (m Menu) Find(id string) (MenuItem, bool)

Find returns the item the menu offers under the action id. Anything else, including a toggle the menu has since flipped, is not found.

type MenuItem struct {
	Label     string     `json:"label,omitempty"`
	Detail    string     `json:"detail,omitempty"`
	Tooltip   string     `json:"tooltip,omitempty"`
	State     State      `json:"state,omitempty"`
	Checked   *bool      `json:"checked,omitempty"`
	Action    string     `json:"action,omitempty"`
	Separator bool       `json:"separator,omitempty"`
	Items     []MenuItem `json:"items,omitempty"`

	// Args is the lerd command behind Action; nil for update, which is not one.
	Args []string `json:"-"`
}

MenuItem is one row. Action is the id to post back to run it; a row without one is information. Checked is set only on toggles and choices.

type MenuOptions struct {
	LANToggle bool // false on macOS, where gvproxy always exposes ports 80/443
}

MenuOptions are the parts of the menu that depend on where lerd runs.

type PHPInfo

type PHPInfo struct {
	Version string
}

type ServiceInfo

type ServiceInfo struct {
	Name               string `json:"name"`
	Status             string `json:"status"`
	Paused             bool   `json:"paused,omitempty"`
	QueueSite          string `json:"queue_site,omitempty"`
	ScheduleWorkerSite string `json:"schedule_worker_site,omitempty"`
	StripeListenerSite string `json:"stripe_listener_site,omitempty"`
	ReverbSite         string `json:"reverb_site,omitempty"`
	HorizonSite        string `json:"horizon_site,omitempty"`
	WorkerSite         string `json:"worker_site,omitempty"`
}

type Settings

type Settings struct {
	Autostart          bool
	LANExposed         bool
	LANServicesExposed bool
	Dumps              bool
	Notifications      bool
	HighContrastIcon   bool
	LatestVersion      string // e.g. "v1.2.0" when an update is available
}

Settings are the persisted lerd toggles the tray menu shows.

func LocalSettings

func LocalSettings() Settings

LocalSettings reads the tray's settings from this machine. The toggles come straight from the config, so the tray shows persisted intent.

type Snapshot

type Snapshot struct {
	Running              bool
	NginxRunning         bool
	DNSOK                bool
	DNSDegraded          bool // lerd-dns healthy but the system resolver is bypassed, typically a VPN
	DNSDisabled          bool // explicit dns.enabled=false from API; zero value falls through to ok/error
	PHPVersions          []PHPInfo
	PHPDefault           string
	Services             []ServiceInfo
	ServicesKnown        bool     // the services call answered; an empty list means none, not unread
	WorkersRunning       int      // per-site worker units currently up
	WorkersDown          []string // sites lerd considers unhealthy, not merely stopped
	AutostartEnabled     bool
	LANExposed           bool   // lerd lan expose state — drives the LAN toggle item
	LANServicesExposed   bool   // explicit managed-service LAN access preference
	DumpsEnabled         bool   // lerd dump on/off state — drives the dump toggle item
	NotificationsEnabled bool   // lerd notify on/off state — drives the notifications toggle item
	HighContrastIcon     bool   // lerd tray icon high-contrast state — green running icon on any panel
	LatestVersion        string // non-empty (e.g. "v0.8.5") when a newer version is available
}

Snapshot holds the state polled from the Lerd API.

func ReadSnapshot

func ReadSnapshot(get Getter, settings func() Settings) *Snapshot

ReadSnapshot reads the tray's state from lerd's API through get, and the toggles through settings, which is only asked once the API has answered.

type State

type State string

State is how a menu entry is doing; each client picks its own colour for it.

const (
	StateRunning  State = "running"
	StateStopped  State = "stopped"
	StateWarning  State = "warning" // up with a caveat, or stopped on purpose
	StateDisabled State = "disabled"
)

Jump to

Keyboard shortcuts

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