dmenu

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

Documentation

Overview

Example
package main

import (
	"context"
	"fmt"
	"log"

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

func main() {
	d := dmenu.New(
		dmenu.WithPrompt("Prompt"),
		dmenu.WithEntries(
			entry.New("with icon", entry.WithIcon("folder")),
			entry.New("plain"),
			entry.New("with meta", entry.WithMeta("find me")),
		),
	)

	ctx := context.Background()

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

	fmt.Println("choice was", s)
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithActive

func WithActive(a 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 WithBallotSelectedString

func WithBallotSelectedString(s string) opt

When multi-select is enabled, prefix this string when element is selected.

default: "☑ "

func WithBallotUnselectedString

func WithBallotUnselectedString(s string) opt

When multi-select is enabled, prefix this string when element is not selected.

default: "☐ "

func WithCaseInsentitive

func WithCaseInsentitive() opt

Makes dmenu searches case-insensitive

func WithDisplayColumnSeparator

func WithDisplayColumnSeparator(s string) opt

The column separator. This is a regex.

default: '\t'

func WithDisplayColumns

func WithDisplayColumns(c string) opt

A comma separated list of columns to show.

func WithEntries

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

func WithFormat

func WithFormat(f string) opt

Allows the output of dmenu to be customized (N is the total number of input entries):

's' selected string 'i' index (0 - (N-1)) 'd' index (1 - N) 'q' quote string 'p' Selected string stripped from Pango markup (Needs to be a valid string) 'f' filter string (user input) 'F' quoted filter string (user input)

default: 's'

func WithInput

func WithInput(f string) opt

Reads from file instead of stdin.

func WithKeepRight

func WithKeepRight() opt

Set ellipsize mode to start. So, the end of the string is visible.

func WithLines

func WithLines(n int) opt

Maximum number of lines the menu may show before scrolling.

default: 15

func WithMarkupRows

func WithMarkupRows() opt

Tell rofi that DMenu input is Pango markup encoded, and should be rendered. See here ⟨https://developer.gnome.org/pygtk/stable/pango-markup- language.html⟩ for details about Pango markup.

func WithMessage

func WithMessage(m string) opt

Add a message line below the filter entry box. Supports Pango markup. For more information on supported markup, see here ⟨https://docs.gtk.org/Pango/pango_markup.html

func WithMultiSelect

func WithMultiSelect() opt

Allow multiple lines to be selected. Adds a small selection indicator to the left of each entry.

func WithNoCustom

func WithNoCustom() opt

Only return a selected item, do not allow custom entry. This mode returns directly when no entries given.

func WithOnlyMatch

func WithOnlyMatch() opt

Only return a selected item, do not allow custom entry. This mode always returns an entry. It will not return if no matching entry is selected.

func WithPassword

func WithPassword() opt

Hide the input text. This should not be considered secure!

func WithPrompt

func WithPrompt(p string) opt

Specify the prompt to show in dmenu mode.

func WithSelect

func WithSelect(s string) opt

Select first line that matches the given string.

func WithSync

func WithSync() opt

Force rofi mode to first read all data from stdin before showing the selection window. This is original dmenu behavior. Note: the default asynchronous mode will also be automatically disabled if used with conflicting options, such as -dump, -only-match or -auto-select.

func WithUrgent

func WithUrgent(u string) opt

Urgent 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 WithWindowID

func WithWindowID(id string) opt

Position rofi over the window with the given X11 window ID.

func WithWindowTitle

func WithWindowTitle(t string) opt

Set name used for the window title. Will be shown as Rofi - title

Types

type Dmenu

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

func New

func New(opts ...opt) *Dmenu

func (*Dmenu) AddEntries

func (d *Dmenu) AddEntries(entries ...*entry.Entry)

func (*Dmenu) Select

func (d *Dmenu) Select(ctx context.Context) (selection string, err error)

Jump to

Keyboard shortcuts

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