launcher

package
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 29 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

Overview

Package launcher is the launcher engine, the rofi-replacement core (crates/wayle-launcher): the Mode contract, the matching and ranking engine, run history with frecency, the rofi hook and template grammar, and the Session that ties them together. Pure logic, no widgets - the surface lives in shell/launcher. The modes themselves are in service/launcher/modes.

Index

Constants

View Source
const ThumbnailScheme = "thumbnail://"

ThumbnailScheme is the icon prefix that asks for a thumbnail.

View Source
const ThumbnailSize = 128

ThumbnailSize is the freedesktop normal thumbnail size in pixels.

Variables

View Source
var DefaultKeybindings = []Binding{
	{"accept-entry", "Return,KP_Enter"},
	{"accept-alt", "Shift+Return"},
	{"accept-custom", "Control+Return"},
	{"accept-custom-alt", "Control+Shift+Return"},
	{"cancel", "Escape,Control+g,Control+bracketleft"},
	{"delete-entry", "Shift+Delete"},
	{"mode-next", "Shift+Right,Control+Tab"},
	{"mode-previous", "Shift+Left,Control+ISO_Left_Tab"},
	{"mode-complete", "Control+l"},
	{"row-up", "Up,Control+p"},
	{"row-down", "Down,Control+n"},
	{"row-left", "Control+Page_Up"},
	{"row-right", "Control+Page_Down"},
	{"row-first", "Home,KP_Home"},
	{"row-last", "End,KP_End"},
	{"row-select", "Control+space"},
	{"page-prev", "Page_Up"},
	{"page-next", "Page_Down"},
	{"element-next", "Tab"},
	{"element-prev", "ISO_Left_Tab"},
	{"toggle-case-sensitivity", "grave,dead_grave"},
	{"toggle-sort", "Alt+grave"},
	{"clear-line", "Control+w"},
	{"move-front", "Control+a"},
	{"move-end", "Control+e"},
	{"move-word-back", "Alt+b,Control+Left"},
	{"move-word-forward", "Alt+f,Control+Right"},
	{"move-char-back", "Left,Control+b"},
	{"move-char-forward", "Right,Control+f"},
	{"remove-word-back", "Control+Alt+h,Control+BackSpace"},
	{"remove-word-forward", "Control+Alt+d"},
	{"remove-char-back", "BackSpace,Shift+BackSpace,Control+h"},
	{"remove-char-forward", "Delete,Control+d"},
	{"remove-to-eol", "Control+k"},
	{"remove-to-sol", "Control+u"},
	{"paste-primary", "Shift+Insert"},
	{"paste-secondary", "Control+v,Insert"},
	{"select-element", "space"},
	{"custom-1", "Alt+1"},
	{"custom-2", "Alt+2"},
	{"custom-3", "Alt+3"},
	{"custom-4", "Alt+4"},
	{"custom-5", "Alt+5"},
	{"custom-6", "Alt+6"},
	{"custom-7", "Alt+7"},
	{"custom-8", "Alt+8"},
	{"custom-9", "Alt+9"},
	{"custom-10", "Alt+0"},
	{"custom-11", "Alt+exclam"},
	{"custom-12", "Alt+at"},
	{"custom-13", "Alt+numbersign"},
	{"custom-14", "Alt+dollar"},
	{"custom-15", "Alt+percent"},
	{"custom-16", "Alt+dead_circumflex"},
	{"custom-17", "Alt+ampersand"},
	{"custom-18", "Alt+asterisk"},
	{"custom-19", "Alt+parenleft"},
}

DefaultKeybindings is rofi's default table (keybinds.rs DEFAULTS): action names are rofi's kb- names without the prefix, keys are comma-separated GTK accelerator names.

View Source
var DefaultMouseBindings = []Binding{
	{"me-select-entry", "MousePrimary"},
	{"me-accept-entry", "MousePrimary,MouseDPrimary"},
	{"me-accept-custom", "Control+MouseDPrimary"},
	{"ml-row-up", "ScrollUp"},
	{"ml-row-down", "ScrollDown"},
	{"ml-row-left", "ScrollLeft"},
	{"ml-row-right", "ScrollRight"},
}

DefaultMouseBindings is rofi-keys(5)'s mouse table, with one deliberate deviation: rofi accepts a row on MouseDPrimary (a double click) and only selects on a single one. lys-shell has always accepted on a single click, so me-accept-entry keeps both; rofi's exact behavior is one `-me-accept-entry MouseDPrimary` away.

View Source
var ErrNoModes = errors.New("launcher: a session needs at least one mode")

ErrNoModes is a session asked to run with no modes.

View Source
var NoRow = Target{}

NoRow targets the typed text rather than a row.

Functions

func AllowsCustom

func AllowsCustom(m Mode) bool

AllowsCustom reports whether m accepts typed text that matches no row: the CustomPolicy answer, true for modes without one.

func AppendHaystack added in v0.3.1

func AppendHaystack(dst []rune, text string) []rune

AppendHaystack appends text as the matcher reads it to dst: one rune per grapheme cluster, its positions counting clusters.

func CachedThumbnail

func CachedThumbnail(file string) (string, bool)

CachedThumbnail returns an existing thumbnail no older than the file, so an edited image never keeps its old picture.

func DataDir

func DataDir() (string, error)

DataDir resolves lys-shell's data directory, $XDG_DATA_HOME/lys-shell or ~/.local/share/lys-shell, creating it (wayle-core ConfigPaths::data_dir).

func DetectTerminal

func DetectTerminal(configured string) string

DetectTerminal resolves the terminal emulator: the configured one, then $TERMINAL, then the first fallback on $PATH, else xterm.

func FireHook

func FireHook(command string, ctx HookContext)

FireHook runs command with ctx substituted, detached. A blank command does nothing; an unparseable one is logged and does nothing.

func Haystack added in v0.3.1

func Haystack(text string) []rune

Haystack is AppendHaystack over fresh memory.

func HookArgv

func HookArgv(command string, ctx HookContext) []string

HookArgv substitutes ctx into command and returns the argv to exec. Empty when the command is blank, does not shell-parse, or renders to nothing but empty placeholders.

func InPath

func InPath(program string) bool

InPath reports whether program is a regular file in some $PATH directory.

func MergeOverrides

func MergeOverrides(layers ...map[string]string) map[string]string

MergeOverrides layers later maps over earlier ones: config first, then the session's flags.

func MimeIcon

func MimeIcon(file string) string

MimeIcon is the icon-theme name for a file with no thumbnail: its mimetype's file glyph.

func Render

func Render(template string, lookup Lookup) string

Render fills a rofi-style template (template.rs): {key} is replaced by its value, and a [...] block is emitted only when every {key} inside it resolved non-empty - rofi's PATTERN semantics for drun-display-format, window-format, ssh-command, and combi. An unknown key renders empty.

func RenderArgv

func RenderArgv(template string, lookup Lookup) []string

RenderArgv renders a template as an argv: shell-split first, then each argument rendered on its own.

The order is deliberately not rofi's. rofi substitutes into the command string and shell-parses the result, so a value holding a space becomes several arguments and a value holding a quote breaks the parse (rofi 2.0.0 runs nothing at all for a row named "it's here"). Splitting first means one placeholder is exactly one argument, whatever is in it, and a value cannot smuggle in more.

Empty when the template does not shell-parse: half a command is worse than none.

func RunArgv

func RunArgv(argv []string)

RunArgv spawns an argv directly, no shell, detached (run_argv).

func RunShell

func RunShell(command string)

RunShell spawns `sh -c command`, detached (spawn.rs run_shell). Failures are logged, not returned: the surface has already closed by the time a child could fail. A blank command runs nothing.

func ThumbnailCacheDir

func ThumbnailCacheDir() string

ThumbnailCacheDir is $XDG_CACHE_HOME/thumbnails/normal (an absolute XDG_CACHE_HOME only), else ~/.cache/thumbnails/normal: the shared spec directory, deliberately not a lys-shell-private one.

func ThumbnailCachePath

func ThumbnailCachePath(file string) string

ThumbnailCachePath is where file's thumbnail lives per the spec: the md5 of its file:// URI, as PNG.

Types

type Action

type Action interface {
	// contains filtered or unexported methods
}

Action is what the surface should do after a mode handled an event.

func ActivateMany

func ActivateMany(ctx context.Context, m Mode, indices []uint32, input string) Action

ActivateMany forwards a multi-select accept: the mode's own MultiActivator, else an accept of the first index (Mode's default).

func Delete

func Delete(ctx context.Context, m Mode, index uint32) Action

Delete forwards shift-delete: the mode's own Deleter, else nothing.

type ActionClose

type ActionClose struct{}

ActionClose is done: hide the surface.

type ActionCopy

type ActionCopy struct{ Text string }

ActionCopy puts Text on the clipboard and ends the session (calc).

type ActionExit

type ActionExit struct {
	// Code is the process exit code: 0 accept, 10..28 kb-custom-N.
	Code int
	// Selected are the accepted rows in input order.
	Selected []Selection
}

ActionExit ends the session with an exit code and the accepted rows (dmenu), forwarded to the waiting CLI.

type ActionNothing

type ActionNothing struct{}

ActionNothing means nothing to do (a state refresh at most).

type ActionReload

type ActionReload struct{ State ModeState }

ActionReload replaces the list, prompt, and message with new state.

type ActionSetInput

type ActionSetInput struct{ Text string }

ActionSetInput replaces the query text.

type ActionSwitchMode

type ActionSwitchMode struct{ Name string }

ActionSwitchMode switches to the named mode (script switch-mode).

type ActionType added in v0.3.3

type ActionType struct{ Text string }

ActionType ends the session and enters Text in the window it leaves focused (emoji).

type ActivateAlt

type ActivateAlt struct{}

ActivateAlt is the alternate accept (Shift+Enter: run in a terminal, the window alt command).

type ActivateCustom

type ActivateCustom struct{ Text string }

ActivateCustom accepts typed text that matches no row.

type ActivateDefault

type ActivateDefault struct{}

ActivateDefault is the plain accept (Enter).

type ActivateKbCustom

type ActivateKbCustom struct{ N uint8 }

ActivateKbCustom is kb-custom-N, N in 1..19 (dmenu and script exit codes 10..28).

type ActivateKind

type ActivateKind interface {
	// contains filtered or unexported methods
}

ActivateKind is how an entry was accepted: ActivateDefault, ActivateAlt, ActivateCustom, or ActivateKbCustom.

type Binding

type Binding struct {
	Action string
	Keys   string
}

Binding is one action and its comma-separated key (or mouse) list.

func EffectiveKeybindings

func EffectiveKeybindings(overrides map[string]string) []Binding

EffectiveKeybindings is DefaultKeybindings with per-action overrides applied ([launcher.keybindings], then per-session -kb-*).

func EffectiveMouseBindings

func EffectiveMouseBindings(overrides map[string]string) []Binding

EffectiveMouseBindings is DefaultMouseBindings with per-action overrides applied ([launcher.mouse-bindings], then -me-*/-ml-*).

type CaseMode

type CaseMode uint8

CaseMode is rofi's case handling (-case-sensitive and -case-smart collapsed).

const (
	// CaseModeInsensitive always folds case.
	CaseModeInsensitive CaseMode = iota
	// CaseModeSmart is sensitive only when the query has an uppercase
	// char.
	CaseModeSmart
	// CaseModeSensitive never folds.
	CaseModeSensitive
)

Case modes.

type CustomPolicy

type CustomPolicy interface {
	AllowsCustom() bool
}

CustomPolicy lets a mode refuse typed text that matches no row. Without it custom input is allowed.

type Deleter

type Deleter interface {
	Delete(ctx context.Context, index uint32) Action
}

Deleter handles shift-delete on a row (history removal, window close). Without it the key does nothing.

type FuzzyQuery added in v0.3.1

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

FuzzyQuery is typed text compiled for searching: each word a fuzzy atom taken literally, none of rofi's or fzf's syntax, so a query like "what's" or "!important" means those characters. It is case-sensitive only when the text has an uppercase letter, and folds accents. Set reuses its memory, so compiling per keystroke allocates nothing once warm; a query belongs to one goroutine.

func NewFuzzyQuery added in v0.3.1

func NewFuzzyQuery(text string) *FuzzyQuery

NewFuzzyQuery compiles text.

func (*FuzzyQuery) AppendPositions added in v0.3.1

func (q *FuzzyQuery) AppendPositions(dst []int, hay []rune) []int

AppendPositions appends to dst the indices into hay of the characters to highlight, ascending and distinct: each word's match, preferring one that starts at a word boundary, then tightened from its end, as a person reading the row would pick them. Words that do not match add nothing.

func (*FuzzyQuery) Empty added in v0.3.1

func (q *FuzzyQuery) Empty() bool

Empty reports a query with no words.

func (*FuzzyQuery) Score added in v0.3.1

func (q *FuzzyQuery) Score(hay []rune) (int, bool)

Score is hay's match quality, false when any word does not match.

func (*FuzzyQuery) Set added in v0.3.1

func (q *FuzzyQuery) Set(text string)

Set recompiles the query for text, over the memory it already has.

func (*FuzzyQuery) Work added in v0.3.3

func (q *FuzzyQuery) Work() uint64

Work is how many characters and matrix cells Score has examined so far, which no clock or load changes.

type History

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

History is the persistent launch history, (mode, entry) -> uses and last use, in the same sqlite file and schema the Rust shell writes ($XDG_DATA_HOME/lys-shell/launcher.db), so an upgrade keeps it.

func DeferHistory added in v0.3.7

func DeferHistory(open func() (*History, error)) *History

DeferHistory is a history that opens through open on its first use, on the goroutine that uses it, so whoever only holds it never touches the disk. A failed open fails every use.

func OpenHistory

func OpenHistory() (*History, error)

OpenHistory opens (creating if needed) the launcher history database.

func OpenHistoryAt

func OpenHistoryAt(path string) (*History, error)

OpenHistoryAt opens a history database at an explicit path; tests use ":memory:".

func (*History) Close

func (h *History) Close() error

Close releases the database; a deferred history no one used stays unopened.

func (*History) Frecency

func (h *History) Frecency(mode string) (map[string]float64, error)

Frecency weights a mode's entries by uses x recency bucket; higher ranks earlier (drun pre-orders its rows by it).

func (*History) FrecencyAt

func (h *History) FrecencyAt(mode string, now int64) (map[string]float64, error)

FrecencyAt is Frecency with an explicit "now".

func (*History) Recent

func (h *History) Recent(mode string) ([]string, error)

Recent lists a mode's entries, most recently used first (rofi run ordering).

func (*History) Record

func (h *History) Record(mode, entry string, maxSize uint32) error

Record counts one launch, pruning the mode's history beyond maxSize.

func (*History) RecordAt

func (h *History) RecordAt(mode, entry string, now int64, maxSize uint32) error

RecordAt is Record with an explicit timestamp.

func (*History) Remove

func (h *History) Remove(mode, entry string) error

Remove forgets one entry (rofi shift-delete).

type HookContext

type HookContext struct {
	// Input is {input}: the query text at the event.
	Input string
	// Entry is {entry}: the row the event is about.
	Entry string
	// Mode is {mode}: the active mode's name.
	Mode string
	// Error is {error}: what went wrong, for -on-menu-error.
	Error string
}

HookContext is what an event knows, for the placeholders.

type Hooks

type Hooks struct {
	// SelectionChanged is -on-selection-changed.
	SelectionChanged string
	// EntryAccepted is -on-entry-accepted.
	EntryAccepted string
	// ModeChanged is -on-mode-changed.
	ModeChanged string
	// MenuCanceled is -on-menu-canceled.
	MenuCanceled string
	// MenuError is -on-menu-error.
	MenuError string
}

Hooks are the commands run when something happens in the menu (rofi -on-*), hooks.rs. rofi's contract, pinned against rofi 2.0.0:

  • the command string is shell-parsed and exec'd directly, never handed to `sh -c`: a $HOME stays literal and a `;` is one more argument, so a row holding shell metacharacters cannot turn a hook into a second command;
  • {input}, {entry}, {mode}, and {error} are substituted where the event has one;
  • nothing arrives on stdin and no ROFI_* variables are exported;
  • the child is detached; the menu does not wait for it.

Where rofi is inconsistent, lys-shell is not: rofi substitutes only for -on-selection-changed and -on-entry-accepted and hands the others their placeholders verbatim. Substituting everywhere is a superset of what a rofi script can rely on.

An empty string is no hook.

func (Hooks) Any

func (h Hooks) Any() bool

Any reports whether any hook is set, so a session that asked for none skips the work of collecting row text.

type Icon

type Icon interface {
	// contains filtered or unexported methods
}

Icon is where a row icon comes from: an IconName, an IconFile, or an IconThumbnail. A nil Icon is no icon.

type IconFile

type IconFile string

IconFile is an image file on disk.

type IconName

type IconName string

IconName is a freedesktop icon-theme name.

type IconThumbnail

type IconThumbnail struct {
	// Path is the file to picture.
	Path string
	// Fallback is the icon-theme name shown until (or instead of) the
	// thumbnail.
	Fallback string
}

IconThumbnail is a thumbnail of Path, generated on demand (rofi thumbnail:// and -preview-cmd). It carries its own Fallback because a file nothing can thumbnail still has to show something, and the row is drawn before any thumbnail exists.

type Item

type Item struct {
	// Display is the text shown (Pango markup when FlagMarkup is set).
	Display string
	// MatchText is what the matcher sees: the display plus invisible
	// meta keywords.
	MatchText string
	// Icon is the optional row icon.
	Icon Icon
	// Info is opaque per-row data handed back on selection (ROFI_INFO);
	// nil when the row carries none.
	Info *string
	// Flags are the row's presentation and behavior bits.
	Flags ItemFlags
}

Item is one list entry. Its index in the mode's item slice is its identity: modes get that index back on activate and delete.

func NewItem

func NewItem(display string) Item

NewItem is a plain item whose display text doubles as its match text.

type ItemFlags

type ItemFlags uint8

ItemFlags is a row's presentation and behavior bits (rofi row metadata).

const (
	// FlagUrgent styles the row urgent (rofi -u, row option urgent).
	FlagUrgent ItemFlags = 1 << iota
	// FlagActive styles the row active (rofi -a, row option active).
	FlagActive
	// FlagNonselectable marks a row that cannot be activated.
	FlagNonselectable
	// FlagPermanent keeps a row visible whatever the filter.
	FlagPermanent
	// FlagMarkup marks the display text as Pango markup.
	FlagMarkup
)

Row flags.

func (ItemFlags) Has

func (f ItemFlags) Has(bits ItemFlags) bool

Has reports whether every bit of f is set.

type Lookup

type Lookup func(key string) (string, bool)

Lookup resolves a template placeholder; false (or an empty value) means absent.

func Values

func Values(m map[string]string) Lookup

Values is a Lookup over a fixed map.

type MatchEngine

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

MatchEngine filters and ranks a mode's items against the query. The fzf-syntax methods (normal, fuzzy, prefix) rewrite the query into nucleo's pattern language and score every item; regex and glob scan. It is synchronous: the engine goroutine calls it per keystroke, which for launcher-sized lists is cheaper than nucleo's worker threads.

func NewMatchEngine

func NewMatchEngine(opts MatcherOptions) *MatchEngine

NewMatchEngine builds an engine with no items.

func (*MatchEngine) Items

func (e *MatchEngine) Items() []Item

Items returns the current items.

func (*MatchEngine) Matched

func (e *MatchEngine) Matched() []uint32

Matched returns the ranked matched item indices plus the trailing PERMANENT rows the filter dropped.

func (*MatchEngine) Options

func (e *MatchEngine) Options() MatcherOptions

Options returns the matching options.

func (*MatchEngine) SetItems

func (e *MatchEngine) SetItems(items []Item)

SetItems replaces the item set (a mode load or reload) and re-runs the query.

func (*MatchEngine) SetOptions

func (e *MatchEngine) SetOptions(opts MatcherOptions)

SetOptions replaces the matching options and re-runs the query.

func (*MatchEngine) SetQuery

func (e *MatchEngine) SetQuery(query string)

SetQuery updates the query and recomputes the matches.

type MatchMethod

type MatchMethod uint8

MatchMethod is rofi's -matching.

const (
	// MatchNormal is tokenized substring matching (rofi's default).
	MatchNormal MatchMethod = iota
	// MatchFuzzy is fzf-style fuzzy matching.
	MatchFuzzy
	// MatchPrefix is tokenized prefix matching.
	MatchPrefix
	// MatchRegex treats the whole query as a regular expression.
	MatchRegex
	// MatchGlob is tokenized glob matching (`*token*` per token).
	MatchGlob
)

Matching methods.

type MatcherOptions

type MatcherOptions struct {
	Method MatchMethod
	Case   CaseMode
	// Tokenize splits the query into independently matched words.
	Tokenize bool
	// Normalize strips accents while matching.
	Normalize bool
	// NegationChar prefixes a token that must not match
	// (-matching-negate-char).
	NegationChar rune
	// Sort ranks results by match quality; off keeps list order (rofi's
	// default).
	Sort       bool
	SortMethod SortMethod
}

MatcherOptions are the matching knobs (matcher.rs MatcherOptions).

func DefaultMatcherOptions

func DefaultMatcherOptions() MatcherOptions

DefaultMatcherOptions is MatcherOptions::default.

type Mode

type Mode interface {
	// Name is the canonical name ("drun", or a script mode's name).
	Name() string
	// Load produces the initial list state.
	Load(ctx context.Context) ModeState
	// Activate handles an accept of a row or of custom input; input is
	// the query text at accept time (ROFI_INPUT).
	Activate(ctx context.Context, target Target, kind ActivateKind, input string) Action
}

Mode is one launch mode (drun, run, window, ssh, script, dmenu, ...). Modes run on the session's engine goroutine; nothing calls them concurrently. The optional behaviors are the Querier, MultiActivator, Deleter, CustomPolicy, and Subsetter interfaces.

type ModeState

type ModeState struct {
	// Items are the rows; the slice index is the row identity.
	Items []Item
	// Prompt is the text left of the input.
	Prompt string
	// Message is the optional (markup) row between input and list; nil
	// for none.
	Message *string
	// MarkupRows renders every row's text as Pango markup.
	MarkupRows bool
	// MultiSelect allows toggling several rows before accepting.
	MultiSelect bool
	// NoCustom rejects custom (non-row) input.
	NoCustom bool
	// UseHotKeys routes kb-custom-N to the mode instead of closing.
	UseHotKeys bool
	// KeepSelection keeps the selected position across a reload
	// (script keep-selection).
	KeepSelection bool
	// NewSelection is an absolute selection to apply (script
	// new-selection); nil for none.
	NewSelection *uint32
	// KeepFilter keeps the typed filter across a reload (script
	// keep-filter).
	KeepFilter bool
	// Password masks the input: what is typed is a secret (a master
	// password), so it shows as dots and no hook is told it.
	Password bool
}

ModeState is everything the surface needs to render a mode's list.

type MouseBinding

type MouseBinding struct {
	Modifiers MouseModifiers
	// Button is the clicked button; zero for a scroll binding.
	Button MouseButton
	// Double requires two presses (MouseD...).
	Double bool
	// Scroll is the wheel direction; zero for a click binding.
	Scroll ScrollDirection
}

MouseBinding is one parsed rofi mouse identifier: modifiers plus either a click (Button, Double) or a scroll (Scroll non-zero).

func ParseMouse

func ParseMouse(spec string) (MouseBinding, bool)

ParseMouse parses one rofi mouse identifier with its modifier prefixes (rofi-keys(5): Mouse<D><Primary|Secondary|Middle|Forward| Back|ExtraN> and Scroll<Up|Down|Left|Right>). A key name is not a mouse binding: the two tables share a config shape, so a mistyped Return is refused rather than bound to some button.

func ParseMouseList

func ParseMouseList(specs string) []MouseBinding

ParseMouseList parses a comma-separated binding list, dropping (and logging) the parts that are not mouse identifiers.

type MouseButton

type MouseButton uint32

MouseButton is a physical button by its pointer button number (1 primary, 2 middle, 3 secondary, 8 back, 9 forward, ExtraN beyond).

const (
	MousePrimary   MouseButton = 1
	MouseMiddle    MouseButton = 2
	MouseSecondary MouseButton = 3
	MouseBack      MouseButton = 8
	MouseForward   MouseButton = 9
)

Named buttons (mouse.rs MouseButton::number).

type MouseModifiers

type MouseModifiers uint8

MouseModifiers are the modifiers held with a mouse binding.

const (
	MouseControl MouseModifiers = 1 << iota
	MouseShift
	MouseAlt
	MouseSuper
)

Mouse binding modifiers.

type MultiActivator

type MultiActivator interface {
	ActivateMany(ctx context.Context, indices []uint32, input string) Action
}

MultiActivator handles a multi-select accept (dmenu). Without it the session activates the first index.

type Previewer added in v0.3.10

type Previewer interface {
	RowPreview(index uint32) (func(context.Context) (image.Image, error), bool)
}

Previewer pictures a row for the search panel's preview pane: the returned func captures it off the UI loop when the row is selected. false leaves the row without a picture.

type Querier

type Querier interface {
	Query(query string) (ModeState, bool)
}

Querier is a mode whose rows are the query's answer rather than something to search through (calc). Query returns the new state, or false to leave the list as it is. It runs on every keystroke, so anything that waits for the world belongs in Load.

type ScrollDirection

type ScrollDirection uint8

ScrollDirection is which way the wheel turned.

const (
	ScrollUp ScrollDirection = iota + 1
	ScrollDown
	ScrollLeft
	ScrollRight
)

Scroll directions.

type Selection

type Selection struct {
	// Index is the row's input index; -1 for accepted custom input.
	Index int64
	// Text is the row text, or the custom input.
	Text string
}

Selection is one accepted row handed back to a dmenu client.

type Session

type Session struct {

	// Engine is the matcher the surface reads matches from.
	Engine *MatchEngine
	// contains filtered or unexported fields
}

Session is one open launcher invocation (session.rs): the loaded modes, the active one, its match state, and the multi-select set. The surface drives it from one goroutine: query edits, accepts, deletes, and mode switches.

func NewSession

func NewSession(modes []Mode, opts MatcherOptions) (*Session, error)

NewSession builds a session over modes, the first active. An empty mode list is ErrNoModes.

func (*Session) Activate

func (s *Session) Activate(ctx context.Context, target Target, kind ActivateKind) Action

Activate forwards an accept to the active mode and resolves the session-internal actions (reload, switch-mode); the rest is the surface's to interpret. While the completer is open an accept fills the query instead of launching. Custom input a mode refuses (or the state marks no-custom) does nothing.

func (*Session) ActivateMany

func (s *Session) ActivateMany(ctx context.Context, indices []uint32) Action

ActivateMany forwards a multi-select accept (dmenu).

func (*Session) ActiveIndex

func (s *Session) ActiveIndex() int

ActiveIndex is the active mode's index.

func (*Session) CancelCompleter

func (s *Session) CancelCompleter(ctx context.Context)

CancelCompleter closes the completer without taking anything from it.

func (*Session) Completing

func (s *Session) Completing() bool

Completing reports whether the completer is open.

func (*Session) Delete

func (s *Session) Delete(ctx context.Context, index uint32) Action

Delete forwards shift-delete to the active mode.

func (*Session) Load

func (s *Session) Load(ctx context.Context)

Load loads (or reloads) the active mode into the engine.

func (*Session) Matched

func (s *Session) Matched() []uint32

Matched returns the ranked matched indices with a combi !bang mask applied.

func (*Session) ModeNames

func (s *Session) ModeNames() []string

ModeNames lists the loaded modes (tabs, kb-mode-next order).

func (*Session) OpenCompleter

func (s *Session) OpenCompleter(ctx context.Context) bool

OpenCompleter opens the completer, remembering where to come back to. False when none is configured, it is not a loaded mode, it is the mode already showing, or it is already open - the key then does nothing rather than switching somewhere arbitrary.

func (*Session) Query

func (s *Session) Query() string

Query is the current query, bang stripped.

func (*Session) SetCompleter

func (s *Session) SetCompleter(mode string)

SetCompleter names the mode kb-mode-complete opens; empty is none.

func (*Session) SetQuery

func (s *Session) SetQuery(query string)

SetQuery updates the query. A leading `!bang ` restricts a combi mode to the matching sub-mode; the remainder is the real query. A mode that answers the query (Querier) rebuilds its list first, so the engine matches against the answer.

func (*Session) State

func (s *Session) State() ModeState

State is the active mode's state (prompt, message, flags).

func (*Session) SwitchNext

func (s *Session) SwitchNext(ctx context.Context)

SwitchNext is kb-mode-next.

func (*Session) SwitchPrevious

func (s *Session) SwitchPrevious(ctx context.Context)

SwitchPrevious is kb-mode-previous.

func (*Session) SwitchTo

func (s *Session) SwitchTo(ctx context.Context, index int)

SwitchTo switches to the mode at index (wrapping) and loads it.

func (*Session) SwitchToNamed

func (s *Session) SwitchToNamed(ctx context.Context, name string) bool

SwitchToNamed switches to a mode by name; false when unknown.

type SortMethod

type SortMethod uint8

SortMethod is rofi's -sorting-method.

const (
	// SortFzf ranks by match quality (the fzf-style score).
	SortFzf SortMethod = iota
	// SortLevenshtein ranks by edit distance to the query.
	SortLevenshtein
)

Sort methods.

type Subsetter

type Subsetter interface {
	Subset(bang string) ([]bool, bool)
}

Subsetter is combi's !bang support: the item mask for a bang prefix (true = shown), false when the bang names no sub-mode.

type Target

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

Target is what an accept is about: one row, or no row (the typed text). The zero Target is no row, so a forgotten index can never silently mean row 0.

func RowTarget

func RowTarget(i uint32) Target

RowTarget targets row index i of the mode's items.

func (Target) Row

func (t Target) Row() (uint32, bool)

Row returns the targeted index, false when the target is no row.

type Thumbnailer

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

Thumbnailer makes thumbnails with -preview-cmd, else the system's XDG thumbnailers.

func NewThumbnailer

func NewThumbnailer(previewCmd string) Thumbnailer

NewThumbnailer uses previewCmd when it is set; a blank one is no command, so it never shadows the system thumbnailers.

func (Thumbnailer) Command

func (t Thumbnailer) Command(file, output string) ([]string, bool)

Command is the argv that would produce file's thumbnail at output, false when nothing here can make one. The -preview-cmd argv is split before substituting and exec'd, never given to a shell: a file name is attacker-controlled in every mode that lists a directory.

func (Thumbnailer) Generate

func (t Thumbnailer) Generate(ctx context.Context, file string) (string, bool)

Generate produces file's thumbnail and returns where it landed; a cached one is returned as is. A file nothing can thumbnail is a normal outcome (false), not an error: the caller keeps the fallback.

type XDGThumbnailer

type XDGThumbnailer struct {
	// Exec still carries its %s %u %i %o.
	Exec      string
	MimeTypes []string
}

XDGThumbnailer is one installed .thumbnailer descriptor.

func ParseThumbnailer

func ParseThumbnailer(contents string) (XDGThumbnailer, bool)

ParseThumbnailer reads Exec and MimeType from a [Thumbnailer Entry] section. A TryExec that is not installed disqualifies the entry, as does a missing Exec or MimeType.

func (XDGThumbnailer) Argv

func (x XDGThumbnailer) Argv(file, output string) ([]string, bool)

Argv is the descriptor's command for file -> output.

Directories

Path Synopsis
Package modes holds the launch modes (crates/wayle-launcher/src/ modes): drun, run, window, ssh, the file browsers, script and dmenu, combi, and the lys-shell-only calc, emoji, clipboard, and keys modes.
Package modes holds the launch modes (crates/wayle-launcher/src/ modes): drun, run, window, ssh, the file browsers, script and dmenu, combi, and the lys-shell-only calc, emoji, clipboard, and keys modes.
Package search is the launcher's search: one ranked list across providers (apps, windows, files, answers, ...), frecency that learns, levels you enter and leave, and the actions of a selected row.
Package search is the launcher's search: one ranked list across providers (apps, windows, files, answers, ...), frecency that learns, levels you enter and leave, and the actions of a selected row.
Package typetext enters text in the focused window through a virtual keyboard, whatever the seat's layout can reach: the keyboard carries a keymap of its own with one key per character.
Package typetext enters text in the focused window through a virtual keyboard, whatever the seat's layout can reach: the keyboard carries a keymap of its own with one key per character.

Jump to

Keyboard shortcuts

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