rofi

package module
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: 0 Imported by: 0

README

go-rofi

Go Report Card MIT Go Reference builds.sr.ht status

This library allows you to programmatically create outputs apt to be used as input to rofi running in script mode.

For example, my-program uses go-rofi to build rofi-script compatible options:

$ rofi -show my-choices -modi "my-choices:my-program"

Usage

var entries []struct{
  URL         string
  Description string
  Icon        string
} {
  {"https://foobar.com", "Some foobar", "nice-icon"},
}

r := rofi.New()

for _, e := range entries {
	r.AddEntries(rofi.NewEntry(
		e.Description,
		rofi.WithInfo(e.URL),
		rofi.WithMeta(e.URL),
		rofi.WithIcon(e.Icon),
	))
}

fmt.Println(r.Build())

You can also have your program execute rofi in script mode by instantiating a Runner:

r := rofi.NewRunner("program-name", runnable)

output, err := r.Run()
if err != nil {
	log.Fatal(err)
}

fmt.Println(output)

You can use dmenu mode to select something within the flow of your program:

d := dmenu.New(
	dmenu.WithPrompt("Choose"),
	dmenu.WithMessage("This is a helpful message"),
	dmenu.WithWindowID("56623151"),
	dmenu.WithEntries(
		entry.New("Hello", entry.WithIcon("folder")),
		entry.New("World", entry.WithInfo("somethin something")),
		entry.New("Hi", entry.WithMeta("find me")),
	),
)

ctx := context.Background()

s, err := d.Select(ctx)
if err != nil {
	log.Fatal(err)
}

fmt.Println("choice was", s)

Documentation

Overview

rofi provides abstractions to interact with rofi successfully

Index

Constants

View Source
const (
	Separator = "\x1f"
	Null      = "\000"
	True      = "true"
)

Variables

This section is empty.

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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