Documentation
¶
Overview ¶
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.
Index ¶
- Variables
- func Eval(input string) (float64, bool)
- func FormatResult(v float64) string
- func GlyphFromCodes(codes []uint32) string
- func IsIgnored(entry string, prefixes []string) bool
- func ParseIcon(value string) launcher.Icon
- func ParseRanges(raw string) []uint32
- type Calc
- type Clipboard
- type ClipboardHistory
- type Combi
- func (c *Combi) Activate(ctx context.Context, target launcher.Target, kind launcher.ActivateKind, ...) launcher.Action
- func (c *Combi) Delete(ctx context.Context, index uint32) launcher.Action
- func (c *Combi) Load(ctx context.Context) launcher.ModeState
- func (*Combi) Name() string
- func (c *Combi) Subset(bang string) ([]bool, bool)
- type Dmenu
- type DmenuConfig
- type Drun
- type DrunConfig
- type DrunField
- type Emoji
- type EmojiMode
- type FileBrowser
- type FileBrowserConfig
- type FileSort
- type Keys
- type Run
- type RunConfig
- type SSH
- type SSHConfig
- type Script
- type Window
- func (w *Window) Activate(ctx context.Context, target launcher.Target, kind launcher.ActivateKind, ...) launcher.Action
- func (*Window) AllowsCustom() bool
- func (w *Window) Delete(ctx context.Context, index uint32) launcher.Action
- func (w *Window) Load(ctx context.Context) launcher.ModeState
- func (w *Window) Name() string
- type WindowConfig
- type WindowField
Constants ¶
This section is empty.
Variables ¶
var AllDrunFields = []DrunField{ DrunFieldName, DrunFieldGeneric, DrunFieldExec, DrunFieldCategories, DrunFieldComment, DrunFieldKeywords, }
AllDrunFields is -drun-match-fields all.
Functions ¶
func Eval ¶
Eval evaluates an expression, false when it is not one. Incomplete input is not an error worth reporting: half of what is typed here is a half-finished expression, so a failure shows no row. Infinite and NaN results are not answers either.
func FormatResult ¶
FormatResult writes a result the way a person would: no trailing zeros, no ".0" on a whole number.
func GlyphFromCodes ¶
GlyphFromCodes assembles the glyph. A 0 is GTK's placeholder for a variation selector or skin tone; with none chosen GTK substitutes U+FE0F, which makes the emoji render as emoji rather than monochrome text, so this does the same. Values that are not characters (a surrogate, past U+10FFFF) are dropped.
func IsIgnored ¶
IsIgnored reports whether an entry is one the user keeps out of history (rofi -ignored-prefixes). It matches the command - the executable for run, the desktop id for drun - because that is what history stores; an empty prefix matches nothing.
func ParseIcon ¶
ParseIcon reads one icon value: a thumbnail:// request, an absolute path, or a theme name.
func ParseRanges ¶
ParseRanges reads a dmenu-style index list, "1,3-5,8"; parts that do not parse are skipped.
Types ¶
type Calc ¶
type Calc struct {
// contains filtered or unexported fields
}
Calc is the calculator mode (calc.rs): the query is an expression and the first row is its result. rofi needs rofi-calc, a plugin, and qalc for this; here it is a mode like any other. Enter copies the result, Shift+Enter puts it back in the input so the next expression builds on it. The evaluator is deliberately small - arithmetic, parentheses, a handful of functions and constants - and does no units; qalc through a script mode is still the answer for those.
func (*Calc) Activate ¶
func (c *Calc) Activate(_ context.Context, _ launcher.Target, kind launcher.ActivateKind, _ string) launcher.Action
Activate copies the result; the alternate accept continues with it.
func (*Calc) AllowsCustom ¶
AllowsCustom is false: typed text is never itself the answer.
type Clipboard ¶
type Clipboard struct {
// contains filtered or unexported fields
}
Clipboard lists the session's clipboard history (clipboard.rs): the cliphist | rofi -dmenu | wl-copy pipeline without a second daemon. Accepting a row puts it back under the mime it arrived with, so a copied file goes back as a file and an image as an image.
func NewClipboard ¶
func NewClipboard(history ClipboardHistory) *Clipboard
NewClipboard builds the mode; a nil history is a compositor without data-control, which the mode says rather than looking empty.
func (*Clipboard) Activate ¶
func (c *Clipboard) Activate(_ context.Context, target launcher.Target, kind launcher.ActivateKind, _ string) launcher.Action
Activate restores the entry; kb-custom-1/2 forget one or all.
type ClipboardHistory ¶
type ClipboardHistory interface {
Entries() *clipboard.Snapshot
Forget(id uint64) bool
Clear()
Copy(id uint64) bool
}
ClipboardHistory is what the clipboard mode needs from the session's clipboard service; *clipboard.Clipboard implements it.
type Combi ¶
type Combi struct {
// contains filtered or unexported fields
}
Combi merges several modes into one list, !bang filterable (combi.rs).
func NewCombi ¶
NewCombi builds over child modes (rofi -combi-modes) with a row template over {mode} and {text}.
func (*Combi) Activate ¶
func (c *Combi) Activate(ctx context.Context, target launcher.Target, kind launcher.ActivateKind, input string) launcher.Action
Activate routes a row to its owner; custom input goes to the first child that accepts it.
type Dmenu ¶
type Dmenu struct {
// contains filtered or unexported fields
}
Dmenu is dmenu mode: rows arrive from the CLI over a channel, and an accept exits the session with the selection (dmenu.rs).
func NewDmenu ¶
func NewDmenu(cfg DmenuConfig, rows <-chan []string) *Dmenu
NewDmenu builds the mode over the CLI's row stream; the channel closes when the rows are done.
func (*Dmenu) Activate ¶
func (d *Dmenu) Activate(_ context.Context, target launcher.Target, kind launcher.ActivateKind, input string) launcher.Action
Activate exits with the row (or the typed text, index -1) and rofi's code: 0, or 9+N for kb-custom-N.
func (*Dmenu) ActivateMany ¶
ActivateMany exits with every picked row, in the given order.
type DmenuConfig ¶
type DmenuConfig struct {
Prompt *string
// Message is -mesg.
NoCustom bool
// Urgent and Active are the -u and -a indices, ranges expanded.
}
DmenuConfig is the part of the CLI's dmenu flags the engine needs.
type Drun ¶
type Drun struct {
// contains filtered or unexported fields
}
Drun launches applications from desktop entries (drun.rs).
func NewDrun ¶
func NewDrun(cfg DrunConfig, history *launcher.History) *Drun
NewDrun builds the mode; a nil history disables frecency and recording.
func (*Drun) Activate ¶
func (d *Drun) Activate(_ context.Context, target launcher.Target, kind launcher.ActivateKind, _ string) launcher.Action
Activate launches the row (recording it); custom input runs as a command, as rofi's drun does.
type DrunConfig ¶
type DrunConfig struct {
// Categories shows only apps in these categories (empty = all).
Categories []string
// ExcludeCategories hides apps in these.
ExcludeCategories []string
MatchFields []DrunField
// DisplayFormat is the row template over {name} {generic} {exec}
// {categories} {comment}, [..] optional.
DisplayFormat string
// ShowActions adds desktop actions as rows.
ShowActions bool
// URLLauncher opens Type=Link entries.
URLLauncher string
// Terminal runs Terminal=true apps; empty autodetects.
Terminal string
MaxHistory uint32
// FallbackIcon is the icon for entries naming none
// (-application-fallback-icon); empty is no icon.
FallbackIcon string
IgnoredPrefixes []string
}
DrunConfig is drun's knobs (rofi's -drun-* family).
func DefaultDrunConfig ¶
func DefaultDrunConfig() DrunConfig
DefaultDrunConfig is DrunConfig::default.
type DrunField ¶
type DrunField uint8
DrunField is a desktop-entry field fed to the matcher (-drun-match-fields).
type Emoji ¶
type Emoji struct {
// Glyph is the emoji itself.
Glyph string
// Name is what to call it, localized where there is a translation.
Name string
// Keywords are everything the matcher sees beyond the name.
Keywords []string
}
Emoji is one emoji as the mode needs it.
func AvailableEmoji ¶
func AvailableEmoji() []Emoji
AvailableEmoji reads the table for the current locale, widening to English. It is parsed once per process.
type EmojiMode ¶
type EmojiMode struct {
// contains filtered or unexported fields
}
EmojiMode picks an emoji by name; accept copies it (emoji.rs).
func (*EmojiMode) Activate ¶
func (m *EmojiMode) Activate(_ context.Context, target launcher.Target, _ launcher.ActivateKind, _ string) launcher.Action
Activate copies the glyph.
func (*EmojiMode) AllowsCustom ¶
AllowsCustom is false: typed text matching no emoji is not an emoji.
type FileBrowser ¶
type FileBrowser struct {
// contains filtered or unexported fields
}
FileBrowser is filebrowser and recursivebrowser (filebrowser.rs).
func NewFileBrowser ¶
func NewFileBrowser(cfg FileBrowserConfig) *FileBrowser
NewFileBrowser roots the browser at the configured directory.
func (*FileBrowser) Activate ¶
func (f *FileBrowser) Activate(_ context.Context, target launcher.Target, kind launcher.ActivateKind, _ string) launcher.Action
Activate enters a directory, opens a file, or follows a typed path.
func (*FileBrowser) Load ¶
func (f *FileBrowser) Load(context.Context) launcher.ModeState
Load lists the current directory.
func (*FileBrowser) Name ¶
func (f *FileBrowser) Name() string
Name is filebrowser or recursivebrowser.
type FileBrowserConfig ¶
type FileBrowserConfig struct {
// Directory is the start directory; empty is $HOME.
Directory string
Sorting FileSort
DirectoriesFirst bool
ShowHidden bool
// Command opens a picked file; empty is xdg-open.
Command string
// Recursive lists every file below (recursivebrowser).
Recursive bool
}
FileBrowserConfig is the file browser's knobs.
func DefaultFileBrowserConfig ¶
func DefaultFileBrowserConfig() FileBrowserConfig
DefaultFileBrowserConfig is FileBrowserConfig::default.
type Keys ¶
type Keys struct {
// contains filtered or unexported fields
}
Keys lists the launcher's own keybindings (keys.rs). Read-only: the rows are informational.
func (*Keys) Activate ¶
func (*Keys) Activate(context.Context, launcher.Target, launcher.ActivateKind, string) launcher.Action
Activate does nothing.
func (*Keys) AllowsCustom ¶
AllowsCustom is false: typed text is not a binding.
type Run ¶
type Run struct {
// contains filtered or unexported fields
}
Run executes commands found on $PATH (run.rs).
func (*Run) Activate ¶
func (r *Run) Activate(_ context.Context, target launcher.Target, kind launcher.ActivateKind, _ string) launcher.Action
Activate runs the row's command or the typed one; Alt runs it in a terminal.
type RunConfig ¶
type RunConfig struct {
// RunCommand is the plain accept template ({cmd}).
RunCommand string
// ShellCommand is the alt accept template ({terminal}, {cmd}).
ShellCommand string
// ListCommand adds its stdout lines as entries.
ListCommand string
// Terminal is the terminal emulator; empty autodetects.
Terminal string
// MaxHistory caps the recorded history.
MaxHistory uint32
// IgnoredPrefixes keeps matching commands out of history.
IgnoredPrefixes []string
}
RunConfig is the run mode's knobs (rofi's -run-* family).
type SSH ¶
type SSH struct {
// contains filtered or unexported fields
}
SSH connects to known hosts in a terminal (ssh.rs).
func (*SSH) Activate ¶
func (s *SSH) Activate(_ context.Context, target launcher.Target, kind launcher.ActivateKind, _ string) launcher.Action
Activate connects to the row's host or the typed one.
type SSHConfig ¶
type SSHConfig struct {
// Client is the ssh binary.
Client string
// Command is the connect template ({terminal}, {ssh-client},
// {host}).
Command string
// ParseHosts adds /etc/hosts names.
ParseHosts bool
// ParseKnownHosts adds ~/.ssh/known_hosts names.
ParseKnownHosts bool
// Terminal is the terminal emulator; empty autodetects.
Terminal string
MaxHistory uint32
}
SSHConfig is the ssh mode's knobs (rofi's -ssh-* family).
type Script ¶
type Script struct {
// contains filtered or unexported fields
}
Script is a custom script mode speaking the rofi-script(5) protocol (script.rs): the script runs with no argument to produce the list, and again with the selected entry as argv[1] on every interaction. ROFI_RETV says why (0 init, 1 select, 2 custom, 3 delete, 10..28 kb-custom-N); ROFI_INFO, ROFI_DATA, and ROFI_INPUT carry the row's info, script-owned state, and the query. Header lines (\0key\x1fvalue) set mode options; row suffixes (text\0icon\x1fname\x1f...) set row metadata.
func (*Script) Activate ¶
func (s *Script) Activate(ctx context.Context, target launcher.Target, kind launcher.ActivateKind, input string) launcher.Action
Activate re-runs the script with the accepted entry.
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window switches between open windows (window.rs).
func NewWindow ¶
func NewWindow(cfg WindowConfig) *Window
NewWindow builds the mode; the compositor is detected from the environment.
func (*Window) Activate ¶
func (w *Window) Activate(ctx context.Context, target launcher.Target, kind launcher.ActivateKind, _ string) launcher.Action
Activate focuses the window, or runs -window-command on Alt.
type WindowConfig ¶
type WindowConfig struct {
// Format is the row template: {w} workspace, {c} class, {t} title,
// {n} name, {r} role.
Format string
MatchFields []WindowField
// HideActive leaves the focused window out.
HideActive bool
// CloseOnDelete makes shift-delete close the window.
CloseOnDelete bool
// WindowCommand is the alt accept command, {window} substituted.
WindowCommand string
// CurrentDesktopOnly restricts the list to the current workspace
// (windowcd).
CurrentDesktopOnly bool
}
WindowConfig is the window mode's knobs (rofi's -window-* family).
func DefaultWindowConfig ¶
func DefaultWindowConfig() WindowConfig
DefaultWindowConfig is WindowConfig::default.
type WindowField ¶
type WindowField uint8
WindowField is a window field fed to the matcher (-window-match-fields).
const ( WindowFieldTitle WindowField = iota WindowFieldClass WindowFieldName WindowFieldRole WindowFieldDesktop )
Window match fields.