script

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithActive

func WithActive(active string) opt

Active row, mark X as active. Where X is a comma-separated list of python(1)-style indices and ranges, e.g. indices start at 0, -1 refers to the last row with -2 preceding it, ranges are left-open and right-close, and so on. You can specify:

  • A single row: '5'
  • A range of (last 3) rows: '-3:'
  • 4 rows starting from row 7: '7:11' (or in legacy notation: '7-10')
  • A set of rows: '2,0,-9'
  • Or any combination: '5,-3:,7:11,2,0,-9'

func WithData

func WithData(data string) opt

Passed data to the next execution of the script via ROFI_DATA.

func WithEntries

func WithEntries(entries ...*entry.Entry) opt

func WithKeepSelection

func WithKeepSelection() opt

If set, the selection is not moved to the first entry, but the current position is maintained. The filter is cleared.

func WithMarkupRows

func WithMarkupRows() opt

Render markup in the row.

func WithMessage

func WithMessage(message string) opt

Update the message text.

func WithNewSelection

func WithNewSelection() opt

If keep-selection is set, this allows you to override the selected entry (absolute position).

func WithNoCustom

func WithNoCustom() opt

Ignore custom input.

func WithPrompt

func WithPrompt(prompt string) opt

Update the prompt text.

func WithTheme

func WithTheme(theme string) opt

Small theme snippet to f.e. change the background color of a widget.

func WithUrgent

func WithUrgent(urgent string) opt

Urgent row, mark X as urgent. Where X is a comma-separated list of python(1)-style indices and ranges, e.g. indices start at 0, -1 refers to the last row with -2 preceding it, ranges are left-open and right-close, and so on. You can specify:

  • A single row: '5'
  • A range of (last 3) rows: '-3:'
  • 4 rows starting from row 7: '7:11' (or in legacy notation: '7-10')
  • A set of rows: '2,0,-9'
  • Or any combination: '5,-3:,7:11,2,0,-9'

func WithUseHotKeys

func WithUseHotKeys() opt

If set to true, it enabled the Custom keybindings for script. Warning this breaks the normal rofi flow.

Types

type CustomRunner

type CustomRunner interface {
	OnCustomSelection(selection, data string) (string, error)
}

CustomRunner represents an object that accepts custom answers

type Runnable

type Runnable interface {
	FirstRun() (string, error)
	OnSelection(selection, info, data string) (string, error)
}

Runnable represents an object that can provide options for rofi-script to run successfully.

type Runner

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

func NewRunner

func NewRunner(name string, runnable Runnable) *Runner

func (*Runner) Run

func (r *Runner) Run() (string, error)

type Script

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

func New

func New(opts ...opt) *Script

func (*Script) AddEntries

func (r *Script) AddEntries(entries ...*entry.Entry)

func (*Script) Build

func (r *Script) Build() string
Example
package main

import (
	"fmt"

	"git.sr.ht/~jcmuller/go-rofi/script"
)

func main() {
	r := script.New()
	fmt.Print(r.Build())

}
Output:

Example (Second)
package main

import (
	"fmt"

	"git.sr.ht/~jcmuller/go-rofi/entry"
	"git.sr.ht/~jcmuller/go-rofi/script"
)

func main() {
	r := script.New(script.WithEntries(
		entry.New("option 1"),
		entry.New("option 2"),
	))

	fmt.Print(r.Build())

}
Output:

option 1
option 2

Jump to

Keyboard shortcuts

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