Skip to content
Dave Davenport edited this page Dec 2, 2019 · 10 revisions

Apart from dmenu mode, rofi can be told to call a custom script.

Basic flow

If you start rofi -modi yourscript:yourscript.sh -show yourscript, this happens:

  1. Rofi calls yourscript.sh without parameters.
  2. Your script needs to write its choices to stdout, separated by line breaks (\n).
  3. Rofi shows these entries and allows the user to choose one.
  4. Your script is called again with the chosen entry as its parameter.

Pass extra properties in script mode

To further improve script mode, support for passing properties exists. You can now set the prompt, a message or use markup and active/urgent colors from the script itself.

It uses the following special ASCII values:

  • \0 indicates end of entry.
  • \x1f is the field separator.
  • \n is the entry separator.

E.g. to set the prompt from a bash mode script:

echo -en "\x00prompt\x1ftesting\n"

Or to mark the first 4 rows urgent and add a message:

echo -en "\x00urgent\x1f0-3\n"
echo -en "\0message\x1fSpecial <b>bold</b> message\n"

The urgent and active syntax is identical to the dmenu command-line argument.

The following commands are supported:

  • message
  • prompt
  • markup-rows
  • urgent
  • active

You can get icon with a row in a similar way:

echo -en "aap\0icon\x1ffolder\n"

Currently only 'icon' is supported.

Advanced configuration

More parameters

You can already let rofi call your script with parameters, by starting it like this: `rofi -modi yourscript:"yourscript.sh first_parameter second_parameter". They will also be included in the last call with the user's choice.

Clone this wiki locally