Documentation
¶
Overview ¶
Package modes holds the launch 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 EntryPreview(history ClipboardHistory, e clipboard.Entry) launcher.Preview
- 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
- func (c *Clipboard) Activate(_ context.Context, target launcher.Target, kind launcher.ActivateKind, ...) launcher.Action
- func (*Clipboard) AllowsCustom() bool
- func (c *Clipboard) Load(context.Context) launcher.ModeState
- func (*Clipboard) Name() string
- func (c *Clipboard) RowPreview(index uint32) (launcher.Preview, bool)
- 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 Conversion
- 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 SkinTone
- 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
- func (w *Window) RowPreview(index uint32) (launcher.Preview, bool)
- type WindowBackend
- type WindowConfig
- type WindowField
- type WindowInfo
Constants ¶
This section is empty.
Variables ¶
var AllDrunFields = []DrunField{ DrunFieldName, DrunFieldGeneric, DrunFieldExec, DrunFieldCategories, DrunFieldComment, DrunFieldKeywords, }
AllDrunFields is -drun-match-fields all.
var SkinTones = [...]SkinTone{ToneLight, ToneMediumLight, ToneMedium, ToneMediumDark, ToneDark}
SkinTones are the five tones an emoji can take, light to dark.
Functions ¶
func EntryPreview ¶
func EntryPreview(history ClipboardHistory, e clipboard.Entry) launcher.Preview
EntryPreview is a clipboard entry's side pane: text whole, an image decoded with its type and size, one copied file as that file, several as their paths, and anything else its type and size. Bytes are copied out of the history only when the row is selected.
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 is the glyph GTK's code points make, with no skin tone.
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: 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: 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 every unpinned one, kb-custom-3 pins or unpins it.
type ClipboardHistory ¶
type ClipboardHistory interface {
Entries() *clipboard.Snapshot
Forget(id uint64) bool
ClearUnpinned()
Copy(id uint64) bool
CanPin() bool
Pin(id uint64) error
Unpin(id uint64) error
}
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.
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 Conversion ¶
type Conversion struct {
// Value is the number alone, Unit its unit.
Value, Unit string
}
Conversion is an answered "5 km to mi".
func Convert ¶
func Convert(query string) (Conversion, bool)
Convert answers "<expression> <unit> to <unit>", false when the query is not one or the units measure different things. Incomplete input is not an error: half of what is typed here is half-finished.
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.
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.
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(ctx context.Context, target launcher.Target, kind launcher.ActivateKind, _ string) launcher.Action
Activate launches the row (recording it); a row that does not launch, one that runs in a terminal with none to run it in included, stays open and says why. 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; empty is the built-in opener.
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 the drun mode without any flag or config.
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, with no skin tone.
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
// contains filtered or unexported fields
}
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 enters it in the focused window.
func NewEmoji ¶
NewEmoji reads the table (once per process); emoji that take a skin tone show and enter it in tone.
func (*EmojiMode) Activate ¶
func (m *EmojiMode) Activate(_ context.Context, target launcher.Target, _ launcher.ActivateKind, _ string) launcher.Action
Activate enters 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.
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 the built-in opener.
Command string
// Terminal runs a Terminal=true opener; empty autodetects.
Terminal string
// Recursive lists every file below (recursivebrowser).
Recursive bool
}
FileBrowserConfig is the file browser's knobs.
func DefaultFileBrowserConfig ¶
func DefaultFileBrowserConfig() FileBrowserConfig
DefaultFileBrowserConfig is the file browser without any flag or config.
type Keys ¶
type Keys struct {
// contains filtered or unexported fields
}
Keys lists the launcher's own keybindings. 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.
func (*Run) Activate ¶
func (r *Run) Activate(ctx 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, and with no terminal to run it in stays open and says so.
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).
func DefaultRunConfig ¶
func DefaultRunConfig() RunConfig
DefaultRunConfig is the run mode without any flag or config.
type SSH ¶
type SSH struct {
// contains filtered or unexported fields
}
SSH connects to known hosts in a terminal.
func (*SSH) Activate ¶
func (s *SSH) Activate(ctx context.Context, target launcher.Target, kind launcher.ActivateKind, _ string) launcher.Action
Activate connects to the row's host or the typed one; with no terminal to connect in it stays open and says so.
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).
func DefaultSSHConfig ¶
func DefaultSSHConfig() SSHConfig
DefaultSSHConfig is the ssh mode without any flag or config.
type Script ¶
type Script struct {
// contains filtered or unexported fields
}
Script is a custom script mode speaking the rofi-script(5) protocol: 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 SkinTone ¶
type SkinTone uint8
SkinTone is the Fitzpatrick modifier person and hand emoji take.
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window switches between open windows.
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 WindowBackend ¶
type WindowBackend interface {
List(ctx context.Context) ([]WindowInfo, error)
Focus(ctx context.Context, id string) error
Close(ctx context.Context, id string) error
}
WindowBackend talks to one compositor over its native IPC client.
func DetectWindows ¶
func DetectWindows() WindowBackend
DetectWindows picks the compositor from the environment, nil when none it can talk to is running.
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 the window mode without any flag or config.
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.
type WindowInfo ¶
type WindowInfo struct {
// ID is the compositor's id: lys-wm IPC id, hyprland address, niri
// id, sway con_id, mango client id.
ID string
Title string
Class string
Workspace string
Focused bool
// FocusOrder is lower for more recently focused windows.
FocusOrder int64
OnCurrentWorkspace bool
// HyprlandAddress is the window's Hyprland address, 0 elsewhere: it
// captures the window through Hyprland's toplevel export.
HyprlandAddress uint64
// ToplevelIdentifier is the window's ext-foreign-toplevel-list
// identifier where the compositor's IPC names it, "" elsewhere, where
// a capture matches the window by class and title.
ToplevelIdentifier string
}
WindowInfo is one open window, compositor-agnostic.
func (WindowInfo) CaptureAt ¶
CaptureAt captures the window's contents scaled down until its smaller side is at most px (sharepreview.ResizeToFit).
func (WindowInfo) Preview ¶
func (win WindowInfo) Preview() launcher.Preview
Preview is the window's side pane: its picture, captured once its row is selected, over its title, application and workspace.