Documentation
¶
Index ¶
Constants ¶
const PlaceholderGlyph = "□"
Variables ¶
var ErrNoTerminal = errors.New("launcher: no terminal found")
var ErrServiceClosed = errors.New("launcher: service closed")
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
ID, Name, GenericName string
Keywords []string
Categories []string
Argv []string
// ExecArgv holds the desktop Exec tokens before terminal wrapping and is
// what ranking searches; empty falls back to Argv (provider entries).
ExecArgv []string
Comment, IconName string
// WorkDir is the desktop entry's Path= working directory, empty when unset.
WorkDir string
Terminal bool
Actions []Action
}
type History ¶
type History struct {
// contains filtered or unexported fields
}
History stores launcher usage for ranking and persists successful activations.
func DefaultHistory ¶
DefaultHistory loads usage history from $XDG_STATE_HOME/sysc-launch/history.gob, falling back to $HOME/.local/state/sysc-launch/history.gob. The logf argument receives history load and save diagnostics; nil suppresses those diagnostics.
type Provider ¶
type Provider struct {
Name string
Prefix string
Glyph string
Description string
Query func(query string) []Result
// Activate runs a row this provider produced, given the routed query.
// Nil means the Applications behaviour: spawn the entry (or its action).
Activate func(query, id, action string) error
// Inline providers are also queried for bare (unprefixed) text; their
// rows are placed above the default provider's.
Inline bool
}
Provider is one launcher source behind a "/" prefix. The registry is an ordered slice; the first entry is the default provider for bare queries. Later providers append without any layout or routing change.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service owns the collector and query goroutines (D12). All state crosses goroutine boundaries as immutable snapshots through channels; no Wayland types appear in this package.
func NewService ¶
func NewService(cfg ServiceConfig) *Service
func (*Service) Activate ¶
Activate runs a row of the last published result set on the service goroutine. A row whose provider has an Activate function goes to it; anything else spawns the entry (or one of its desktop actions) through `niri msg action spawn` (D6/D9). Usage is recorded only on success.
func (*Service) Open ¶
func (s *Service) Open()
Open triggers a rescan when the entry snapshot is stale.
type ServiceConfig ¶
type ServiceConfig struct {
Scan func() []Entry
History *History
Rank func(entries []Entry, query string, boost func(query, identifier string) int) []Result
Run func(ctx context.Context, argv []string) error
Getenv func(string) string
LookPath func(string) (string, error)
Now func() time.Time
Logf func(string, ...any)
StaleAfter time.Duration
ActivateTimeout time.Duration
// Providers are appended after Applications, in order. A provider whose
// prefix is empty, lacks the leading "/", repeats an earlier one, or is
// "/apps" is logged and skipped. Provider functions run on the service
// goroutine and block queries and activation while they run, so they
// must not call back into the Service.
Providers []Provider
// ApplicationsGlyph is the Applications row's overview glyph; empty
// uses PlaceholderGlyph.
ApplicationsGlyph string
}
ServiceConfig wires the launcher service. Nil Scan, Rank, Run, Getenv, LookPath, and Now use the XDG desktop scanner, built-in ranker, Niri spawn, os.Getenv, exec.LookPath, and time.Now. Non-positive StaleAfter and ActivateTimeout use one minute and five seconds. Nil History disables usage persistence and boosting; nil Logf suppresses scanner and provider diagnostics.

