NAME

Rofi::Script - perl interface to the rofi menu

DESCRIPTION

rofi is a lightweight, extensible, scriptable, menu interface for Linux. It has a scripting API documented in man rofi-script. This module is a perl interface to that API.

SYNOPSIS

use Rofi::Script;

if (rofi->is_initial_call) {
    rofi->set_prompt("Please select one")
        ->add_option("Show markup example");
}

SWITCH: for (rofi->shift_arg) {
    next unless $_;

    /markup/ && rofi
        ->set_prompt("markup")
        ->enable_markup_rows
        ->add_option(qq{<i>You can use pango for markup</i>});
}

EXPORTED FUNCTIONS

rofi

rofi
  ->set_prompt('Please choose')
  ->add_option("Foo")
  ->add_option("Bar");
if rofi->is_initial_call;

if (my $cmd = rofi->shift_arg) {
  $cmd =~ /foo/ && rofi
    ->set_prompt("foo")
    ->add_option("bar");
}

...etc

This is a god object that's the primary interface to the entire script interface. This object uses a fluid configuration style where you can chain various methods and configuration options.

With the standard initialization, the object returned by rofi will:

  • Parse args from @ARGV

  • Print output to STDOUT (this is how the rofi app actually displays things)

METHODS

get_args

Gets the arguments "rofi" is aware of.

set_args

Setter for the args "rofi" cares about.

shift_arg

my $cmd = rofi->shift_arg

Shift the leading arg from the args queue. This is how you would navigate your way through the rofi's "call stack"

add_option

rofi->add_option("Choice #1");

Add a row to rofi's output. If you select a row, it will cause your script to be re-called, with the selected row pushed onto the args stack.

show

rofi->show;

Renders the script output to whatever handle was set by "set_show_handle". By default, this goes to STDOUT.

set_show_handle

my $str = '';
open my $h, '>', $str;
rofi->set_show_handle($h);

Set the handle that is printed to by show.

get_show_handle

my $h = rofi->get_show_handle;
close $h;

Return the output handle used by "show", set by "set_show_handle".

is_initial_call

True if this is the first time the script is being called

provided_entry_selected

The user selected a value from the list of provided entries

custom_entry_selected

User manually entered a value on the previous run

set_prompt

rofi->set_prompt("Please select a value");

Set the prompt on the rofi popup

set_message

Set a message in the rofi box

enable_markup_rows

Turn on pango markup for rows

disable_markup_rows

Turn off pango markup for rows

markup_rows_enabled

Query whether or not markup rows are enabled

set_delim

Change the delimiter used to indicate new lines. This is \n by default. There's not really a need to mess with this. I'm not even sure it's implemented 100% correctly.

set_no_custom

Call this to ignore any custom entries from the user

use_hot_keys

Something to do with custom keybinds from the user. This isn't implemented. I haven't needed it yet.

debug

rofi->debug

Dump the contents of the "rofi" object to STDERR