Documentation ¶
Overview ¶
Rofi is a versatile application launcher and window switcher for X11. The "rofigo" package allows you to easily create and display interactive menus in your command-line applications using Rofi. With "rofigo," you can define custom menus with items, labels, icons, and actions, providing a user-friendly way to navigate and interact with your application.
Key Components ¶
This package consists of the following key components:
MenuItem: Represents an item within a menu. Each MenuItem has a label, an associated action, and an optional icon. Menu items can be customized to perform specific actions when selected.
Menu: Represents a collection of menu items along with an optional prompt. Menus are used to group related items together and provide a user-friendly interface for selecting actions.
RofiRunner: A utility for running Rofi-based menus with custom options. You can create an instance of RofiRunner and execute Rofi menus with specific settings, such as prompts and menu items.
Usage Example ¶
Here's a simple example of how to use "rofigo" to create a menu and run it with Rofi:
// Create a menu myMenu := rofigo.NewMenu().WithPrompt("Select an option:") // Add menu items item1 := rofigo.NewMenuItem("Option 1", func() error { // Define the action for Option 1 // ... return nil }, "") item2 := rofigo.NewMenuItem("Option 2", func() error { // Define the action for Option 2 // ... return nil }, "") myMenu.WithItems(item1, item2) // Create a RofiRunner and run the menu runner := rofigo.NewRofiRunner(myMenu) runner.Run()
This code creates a menu with two options and executes it using Rofi.
Package Dependencies ¶
The "rofigo" package relies on external tools like Rofi, so make sure you have Rofi installed on your system to use this package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Menu ¶
Menu represents a collection of menu items along with an optional prompt.
func NewMenu ¶
func NewMenu() *Menu
NewMenu creates a new Menu with an empty prompt and an empty list of items.
func (*Menu) WithItem ¶
WithItem adds a single MenuItem to the Menu and returns the modified Menu. You can use this method to customize the menu by adding individual items.
func (*Menu) WithPrompt ¶
WithPrompt sets the prompt text for the menu and returns the modified Menu.
type MenuItem ¶
MenuItem represents an item within a menu. Each MenuItem has a label, an associated action, and an optional icon.
type RofiRunner ¶
type RofiRunner struct {
Menu *Menu
}
RofiRunner is a utility for running Rofi-based menus with custom options.
func NewRofiRunner ¶
func NewRofiRunner(menu *Menu) *RofiRunner
NewRofiRunner creates a new RofiRunner instance with the specified menu.
func (*RofiRunner) Run ¶
func (r *RofiRunner) Run()
Run executes the Rofi menu using the specified options and runs the associated action when an item is selected.