2024-03-05 10:22:47 -05:00
|
|
|
# rofi-script(5)
|
2020-02-02 11:21:21 -05:00
|
|
|
|
|
|
|
## NAME
|
|
|
|
|
2022-02-23 16:42:56 -05:00
|
|
|
**rofi script mode** - Rofi format for scriptable mode.
|
2020-02-02 11:21:21 -05:00
|
|
|
|
|
|
|
## DESCRIPTION
|
|
|
|
|
2022-07-31 10:28:05 -04:00
|
|
|
**rofi** supports modes that use simple scripts in the background to generate a
|
|
|
|
list and process the result from user actions. This provide a simple interface
|
|
|
|
to make simple extensions to rofi.
|
2020-02-02 11:21:21 -05:00
|
|
|
|
|
|
|
## USAGE
|
|
|
|
|
2023-03-27 06:08:54 -04:00
|
|
|
To specify a script mode, set a mode with the following syntax:
|
|
|
|
"{name}:{executable}"
|
2020-02-02 11:21:21 -05:00
|
|
|
|
|
|
|
For example:
|
|
|
|
|
2023-03-27 06:08:54 -04:00
|
|
|
```bash
|
2022-02-23 16:42:56 -05:00
|
|
|
rofi -show fb -modes "fb:file_browser.sh"
|
2020-02-02 11:21:21 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
The name should be unique.
|
|
|
|
|
|
|
|
## API
|
|
|
|
|
2022-07-31 10:28:05 -04:00
|
|
|
Rofi calls the executable without arguments on startup. This should generate a
|
|
|
|
list of options, separated by a newline (`\n`) (This can be changed by the
|
|
|
|
script). If the user selects an option, rofi calls the executable with the text
|
|
|
|
of that option as the first argument. If the script returns no entries, rofi
|
|
|
|
quits.
|
2020-02-02 11:21:21 -05:00
|
|
|
|
|
|
|
A simple script would be:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
if [ x"$@" = x"quit" ]
|
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
echo "reload"
|
|
|
|
echo "quit"
|
|
|
|
|
|
|
|
```
|
|
|
|
|
2023-03-27 06:08:54 -04:00
|
|
|
This shows two entries, reload and quit. When the quit entry is selected, rofi
|
|
|
|
closes.
|
2020-02-02 11:21:21 -05:00
|
|
|
|
2020-04-05 06:55:00 -04:00
|
|
|
## Environment
|
|
|
|
|
|
|
|
Rofi sets the following environment variable when executing the script:
|
|
|
|
|
|
|
|
### `ROFI_RETV`
|
|
|
|
|
|
|
|
An integer number with the current state:
|
|
|
|
|
2023-03-27 06:08:54 -04:00
|
|
|
- **0**: Initial call of script.
|
|
|
|
- **1**: Selected an entry.
|
|
|
|
- **2**: Selected a custom entry.
|
|
|
|
- **10-28**: Custom keybinding 1-19 ( need to be explicitly enabled by script ).
|
2020-04-05 06:55:00 -04:00
|
|
|
|
2020-05-24 13:09:06 -04:00
|
|
|
### `ROFI_INFO`
|
|
|
|
|
2023-03-27 06:08:54 -04:00
|
|
|
Environment get set when selected entry get set with the property value of the
|
|
|
|
'info' row option, if set.
|
2020-05-24 13:09:06 -04:00
|
|
|
|
2022-03-02 16:06:04 -05:00
|
|
|
### `ROFI_DATA`
|
|
|
|
|
|
|
|
Environment get set when script sets `data` option in header.
|
|
|
|
|
2020-02-02 11:21:21 -05:00
|
|
|
## Passing mode options
|
|
|
|
|
2023-03-27 06:08:54 -04:00
|
|
|
Extra options, like setting the prompt, can be set by the script. Extra options
|
|
|
|
are lines that start with a NULL character (`\0`) followed by a key, separator
|
|
|
|
(`\x1f`) and value.
|
2020-02-02 11:21:21 -05:00
|
|
|
|
|
|
|
For example to set the prompt:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
echo -en "\0prompt\x1fChange prompt\n"
|
|
|
|
```
|
|
|
|
|
|
|
|
The following extra options exists:
|
|
|
|
|
2023-03-27 06:08:54 -04:00
|
|
|
- **prompt**: Update the prompt text.
|
|
|
|
|
|
|
|
- **message**: Update the message text.
|
|
|
|
|
|
|
|
- **markup-rows**: If 'true' renders markup in the row.
|
|
|
|
|
|
|
|
- **urgent**: Mark rows as urgent. (for syntax see the urgent option in
|
|
|
|
dmenu mode)
|
|
|
|
|
|
|
|
- **active**: Mark rows as active. (for syntax see the active option in
|
|
|
|
dmenu mode)
|
|
|
|
|
|
|
|
- **delim**: Set the delimiter for for next rows. Default is '\n' and
|
|
|
|
this option should finish with this. Only call this on first call of script,
|
|
|
|
it is remembered for consecutive calls.
|
|
|
|
|
|
|
|
- **no-custom**: If set to 'true'; only accept listed entries, ignore custom
|
|
|
|
input.
|
|
|
|
|
|
|
|
- **use-hot-keys**: If set to true, it enabled the Custom keybindings for
|
|
|
|
script. Warning this breaks the normal rofi flow.
|
|
|
|
|
|
|
|
- **keep-selection**: If set, the selection is not moved to the first entry,
|
|
|
|
but the current position is maintained. The filter is cleared.
|
|
|
|
|
|
|
|
- **new-selection**: If `keep-selection` is set, this allows you to override
|
|
|
|
the selected entry (absolute position).
|
|
|
|
|
|
|
|
- **data**: Passed data to the next execution of the script via
|
|
|
|
**ROFI\_DATA**.
|
|
|
|
|
|
|
|
- **theme**: Small theme snippet to f.e. change the background color of
|
|
|
|
a widget.
|
2020-02-02 11:21:21 -05:00
|
|
|
|
2023-11-10 08:41:48 -05:00
|
|
|
The **theme** property cannot change the interface while running, it is only
|
2023-11-10 08:45:26 -05:00
|
|
|
usable for small changes in, for example background color, of widgets that get
|
|
|
|
updated during display like the row color of the listview.
|
2023-11-10 08:41:48 -05:00
|
|
|
|
2020-02-02 11:21:21 -05:00
|
|
|
## Parsing row options
|
|
|
|
|
2023-03-27 06:08:54 -04:00
|
|
|
Extra options for individual rows can be set. The extra option can be specified
|
|
|
|
following the same syntax as mode option, but following the entry.
|
2020-02-02 11:21:21 -05:00
|
|
|
|
|
|
|
For example:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
echo -en "aap\0icon\x1ffolder\n"
|
|
|
|
```
|
|
|
|
|
|
|
|
The following options are supported:
|
|
|
|
|
2023-03-27 06:08:54 -04:00
|
|
|
- **icon**: Set the icon for that row.
|
|
|
|
|
2024-01-04 05:26:07 -05:00
|
|
|
- **display**: Replace the displayed string. (Original string will still be used for filtering)
|
2023-11-06 14:02:48 -05:00
|
|
|
|
2024-01-04 05:26:07 -05:00
|
|
|
- **meta**: Specify invisible search terms used for filtering.
|
2023-03-27 06:08:54 -04:00
|
|
|
|
|
|
|
- **nonselectable**: If true the row cannot activated.
|
|
|
|
|
2024-02-28 14:47:18 -05:00
|
|
|
- **permantent**: If true the row always shows, independent of filter.
|
|
|
|
|
2023-03-27 06:08:54 -04:00
|
|
|
- **info**: Info that, on selection, gets placed in the `ROFI_INFO`
|
2024-01-04 05:26:07 -05:00
|
|
|
environment variable. This entry does not get searched for filtering.
|
2023-03-27 06:08:54 -04:00
|
|
|
|
|
|
|
- **urgent**: Set urgent flag on entry (true/false)
|
|
|
|
|
|
|
|
- **active**: Set active flag on entry (true/false)
|
2020-05-24 13:09:06 -04:00
|
|
|
|
|
|
|
multiple entries can be passed using the `\x1f` separator.
|
|
|
|
|
|
|
|
```bash
|
|
|
|
echo -en "aap\0icon\x1ffolder\x1finfo\x1ftest\n"
|
|
|
|
```
|
2020-02-02 11:21:21 -05:00
|
|
|
|
2021-03-10 14:45:53 -05:00
|
|
|
## Executing external program
|
|
|
|
|
2023-03-27 06:08:54 -04:00
|
|
|
If you want to launch an external program from the script, you need to make
|
|
|
|
sure it is launched in the background. If not rofi will wait for its output (to
|
|
|
|
display).
|
2021-03-10 14:45:53 -05:00
|
|
|
|
|
|
|
In bash the best way to do this is using `coproc`.
|
|
|
|
|
|
|
|
```bash
|
|
|
|
coproc ( myApp > /dev/null 2>&1 )
|
|
|
|
```
|
|
|
|
|
2020-09-25 07:29:03 -04:00
|
|
|
## DASH shell
|
|
|
|
|
2023-03-27 06:08:54 -04:00
|
|
|
If you use the `dash` shell for your script, take special care with how dash
|
|
|
|
handles escaped values for the separators. See issue #1201 on github.
|
2020-02-02 11:21:21 -05:00
|
|
|
|
2023-03-26 07:57:50 -04:00
|
|
|
## Script locations
|
|
|
|
|
|
|
|
To specify a script there are the following options:
|
|
|
|
|
2023-03-27 06:08:54 -04:00
|
|
|
- Specify an absolute path to the script.
|
|
|
|
- The script is executable and located in your $PATH
|
2023-03-26 07:57:50 -04:00
|
|
|
|
|
|
|
Scripts located in the following location are loaded on startup:
|
|
|
|
|
2023-03-27 06:08:54 -04:00
|
|
|
- The script is in `$XDG_CONFIG_PATH/rofi/scripts/`, this is usually
|
|
|
|
`~/.config/rofi/scripts/`.
|
2020-02-02 11:21:21 -05:00
|
|
|
|
|
|
|
## SEE ALSO
|
|
|
|
|
2023-03-27 06:08:54 -04:00
|
|
|
rofi(1), rofi-sensible-terminal(1), dmenu(1), rofi-theme(5),
|
|
|
|
rofi-theme-selector(1)
|
2020-02-02 11:21:21 -05:00
|
|
|
|
|
|
|
## AUTHOR
|
|
|
|
|
|
|
|
Qball Cow <qball@gmpclient.org>
|
|
|
|
|
|
|
|
Rasmus Steinke <rasi@xssn.at>
|
|
|
|
|
2022-02-26 11:02:26 -05:00
|
|
|
Morgane Glidic <sardemff7+rofi@sardemff7.net>
|
2020-02-02 11:21:21 -05:00
|
|
|
|
|
|
|
Original code based on work by: Sean Pringle <sean.pringle@gmail.com>
|
|
|
|
|
|
|
|
For a full list of authors, check the AUTHORS file.
|