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 CommandProviderConfig ¶ added in v0.3.1
type CommandProviderConfig struct {
Name, Prefix, Glyph, Description string
Command []string
OnSelect func(query, selection string) error
}
CommandProviderConfig describes one argv-based source of launcher rows. Command emits one row per line as `label\tcomment`; each argv token may contain `{query}`, which is replaced with the query as data. OnSelect gets the original query and the full selected line. Nil OnSelect reports an activation error instead of falling through to application spawning.
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
// TerminalApp is true when this entry names a supported terminal emulator
// whose argv can wrap Terminal=true applications with -e.
TerminalApp 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.
func CommandProvider ¶ added in v0.3.1
func CommandProvider(cfg CommandProviderConfig) Provider
CommandProvider adapts a bounded stdout command to the existing provider path. Results use their source line as a stable selection identity.
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 `<compositor> msg action spawn`, where the compositor CLI is sysc-compositor or else niri (D6/D9). Usage is recorded only on success.
func (*Service) Applications ¶ added in v0.3.0
Applications waits for the initial scan and returns a detached copy of the latest installed-application snapshot. Closing or changing the returned entries cannot affect the launcher's state.
func (*Service) Open ¶
func (s *Service) Open()
Open triggers a rescan when the entry snapshot is stale.
func (*Service) RefreshApplications ¶ added in v0.3.1
RefreshApplications rescans installed applications when the current scan is stale and returns a detached copy after the current snapshot is published.
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
// TerminalDesktopID returns the current stable desktop ID of the selected
// terminal app. It is read for each activation so a config reload takes
// effect without replacing the service.
TerminalDesktopID func() string
}
ServiceConfig wires the launcher service. Nil Scan, Rank, Run, Getenv, LookPath, and Now use the XDG desktop scanner, built-in ranker, compositor 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.

