widgets

package
v0.0.214 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SubstArgs

func SubstArgs(argv []string, placeholder, value string) []string

SubstArgs returns a copy of argv with all occurrences of placeholder replaced by value.

Types

type Manager

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

Manager discovers and manages widget sub-processes.

func NewManager

func NewManager(widgetsDir, basePath string) *Manager

NewManager creates a manager, scans widgetsDir, and starts the idle reaper.

func (*Manager) Close

func (m *Manager) Close()

Close stops all widget processes and the idle reaper.

func (*Manager) LoadErrors

func (m *Manager) LoadErrors() []error

LoadErrors returns errors from the last scan.

func (*Manager) Proxy

func (m *Manager) Proxy(mount string, w http.ResponseWriter, r *http.Request)

Proxy forwards r to the widget identified by mount. The path in r must already have the /widgets/<mount> prefix stripped.

func (*Manager) Reload

func (m *Manager) Reload() []error

Reload re-scans widgetsDir and returns any load errors.

func (*Manager) Status

func (m *Manager) Status() []WidgetStatus

Status returns current status for all loaded widgets.

func (*Manager) StopMount

func (m *Manager) StopMount(mount string) error

StopMount stops the process for the named mount.

type Manifest

type Manifest struct {
	Title       string   `yaml:"title"`
	Command     []string `yaml:"command"`
	Mount       string   `yaml:"mount"`
	Description string   `yaml:"description"`

	// Set by ScanDir, not from YAML.
	ID  string
	Dir string
}

Manifest is the parsed contents of a widget.yaml file.

func ScanDir

func ScanDir(widgetsDir string) ([]*Manifest, []error)

ScanDir scans widgetsDir for widget.yaml manifests. Directories without widget.yaml are silently skipped. Returns valid manifests (sorted by directory name) and any per-widget errors. A missing widgetsDir is treated as no widgets (no error).

func (*Manifest) PlaceholderMode

func (m *Manifest) PlaceholderMode() (string, error)

PlaceholderMode returns "socket" or "port" based on which placeholder appears in Command. Returns an error if both or neither are present.

type WidgetStatus

type WidgetStatus struct {
	ID          string `json:"id"`
	Mount       string `json:"mount"`
	Title       string `json:"title"`
	Description string `json:"description,omitempty"`
	State       string `json:"state"`
	Error       string `json:"error,omitempty"`
	Port        int    `json:"port,omitempty"`
}

WidgetStatus describes the current state of a widget.

Jump to

Keyboard shortcuts

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