2022-10-22 05:03:11 -04:00
|
|
|
.nh
|
|
|
|
.TH ROFI-SCRIPT 5 rofi-script
|
2020-02-02 15:34:14 -05:00
|
|
|
.SH NAME
|
|
|
|
.PP
|
2022-10-22 05:03:11 -04:00
|
|
|
\fBrofi script mode\fP - Rofi format for scriptable mode.
|
2020-02-02 15:34:14 -05:00
|
|
|
|
|
|
|
.SH DESCRIPTION
|
|
|
|
.PP
|
2022-07-31 10:28:05 -04:00
|
|
|
\fBrofi\fP 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 15:34:14 -05:00
|
|
|
|
|
|
|
.SH USAGE
|
|
|
|
.PP
|
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 15:34:14 -05:00
|
|
|
|
|
|
|
.PP
|
|
|
|
For example:
|
|
|
|
|
|
|
|
.PP
|
|
|
|
.RS
|
|
|
|
|
|
|
|
.nf
|
2022-10-22 05:03:11 -04:00
|
|
|
rofi -show fb -modes "fb:file_browser.sh"
|
2020-02-02 15:34:14 -05:00
|
|
|
|
|
|
|
.fi
|
|
|
|
.RE
|
|
|
|
|
|
|
|
.PP
|
|
|
|
The name should be unique.
|
|
|
|
|
|
|
|
.SH API
|
|
|
|
.PP
|
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 (\fB\fC\\n\fR) (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 15:34:14 -05:00
|
|
|
|
|
|
|
.PP
|
|
|
|
A simple script would be:
|
|
|
|
|
|
|
|
.PP
|
|
|
|
.RS
|
|
|
|
|
|
|
|
.nf
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
if [ x"$@" = x"quit" ]
|
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
echo "reload"
|
|
|
|
echo "quit"
|
|
|
|
|
|
|
|
|
|
|
|
.fi
|
|
|
|
.RE
|
|
|
|
|
|
|
|
.PP
|
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 15:34:14 -05:00
|
|
|
|
2020-04-05 06:55:00 -04:00
|
|
|
.SH Environment
|
|
|
|
.PP
|
|
|
|
Rofi sets the following environment variable when executing the script:
|
|
|
|
|
2022-10-22 05:03:11 -04:00
|
|
|
.SS \fB\fCROFI_RETV\fR
|
2020-04-05 06:55:00 -04:00
|
|
|
.PP
|
|
|
|
An integer number with the current state:
|
2021-06-15 14:10:04 -04:00
|
|
|
|
|
|
|
.RS
|
2020-04-05 06:55:00 -04:00
|
|
|
.IP \(bu 2
|
|
|
|
\fB0\fP: Initial call of script.
|
|
|
|
.IP \(bu 2
|
|
|
|
\fB1\fP: Selected an entry.
|
|
|
|
.IP \(bu 2
|
|
|
|
\fB2\fP: Selected a custom entry.
|
|
|
|
.IP \(bu 2
|
2022-10-22 05:03:11 -04:00
|
|
|
\fB10-28\fP: Custom keybinding 1-19 ( need to be explicitly enabled by script ).
|
2021-05-02 14:01:03 -04:00
|
|
|
|
2021-06-15 14:10:04 -04:00
|
|
|
.RE
|
|
|
|
|
2022-10-22 05:03:11 -04:00
|
|
|
.SS \fB\fCROFI_INFO\fR
|
2020-05-24 13:09:06 -04:00
|
|
|
.PP
|
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-10-22 05:03:11 -04:00
|
|
|
.SS \fB\fCROFI_DATA\fR
|
2022-03-02 16:06:04 -05:00
|
|
|
.PP
|
|
|
|
Environment get set when script sets \fB\fCdata\fR option in header.
|
|
|
|
|
2020-02-02 15:34:14 -05:00
|
|
|
.SH Passing mode options
|
|
|
|
.PP
|
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 (\fB\fC\\0\fR) followed by a key, separator
|
|
|
|
(\fB\fC\\x1f\fR) and value.
|
2020-02-02 15:34:14 -05:00
|
|
|
|
|
|
|
.PP
|
|
|
|
For example to set the prompt:
|
|
|
|
|
|
|
|
.PP
|
|
|
|
.RS
|
|
|
|
|
|
|
|
.nf
|
2022-10-22 05:03:11 -04:00
|
|
|
echo -en "\\0prompt\\x1fChange prompt\\n"
|
2020-02-02 15:34:14 -05:00
|
|
|
|
|
|
|
.fi
|
|
|
|
.RE
|
|
|
|
|
|
|
|
.PP
|
|
|
|
The following extra options exists:
|
2021-06-15 14:10:04 -04:00
|
|
|
|
|
|
|
.RS
|
2020-02-02 15:34:14 -05:00
|
|
|
.IP \(bu 2
|
|
|
|
\fBprompt\fP: Update the prompt text.
|
|
|
|
.IP \(bu 2
|
|
|
|
\fBmessage\fP: Update the message text.
|
|
|
|
.IP \(bu 2
|
2022-10-22 05:03:11 -04:00
|
|
|
\fBmarkup-rows\fP: If 'true' renders markup in the row.
|
2020-02-02 15:34:14 -05:00
|
|
|
.IP \(bu 2
|
2023-03-27 06:08:54 -04:00
|
|
|
\fBurgent\fP: Mark rows as urgent. (for syntax see the urgent option in
|
|
|
|
dmenu mode)
|
2020-02-02 15:34:14 -05:00
|
|
|
.IP \(bu 2
|
2023-03-27 06:08:54 -04:00
|
|
|
\fBactive\fP: Mark rows as active. (for syntax see the active option in
|
|
|
|
dmenu mode)
|
2020-04-01 08:00:48 -04:00
|
|
|
.IP \(bu 2
|
2023-03-27 06:08:54 -04:00
|
|
|
\fBdelim\fP: 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.
|
2020-04-22 17:41:25 -04:00
|
|
|
.IP \(bu 2
|
2023-03-27 06:08:54 -04:00
|
|
|
\fBno-custom\fP: If set to 'true'; only accept listed entries, ignore custom
|
|
|
|
input.
|
2021-05-31 08:21:09 -04:00
|
|
|
.IP \(bu 2
|
2023-03-27 06:08:54 -04:00
|
|
|
\fBuse-hot-keys\fP: If set to true, it enabled the Custom keybindings for
|
|
|
|
script. Warning this breaks the normal rofi flow.
|
2022-03-02 16:06:04 -05:00
|
|
|
.IP \(bu 2
|
2023-03-27 06:08:54 -04:00
|
|
|
\fBkeep-selection\fP: If set, the selection is not moved to the first entry,
|
|
|
|
but the current position is maintained. The filter is cleared.
|
2022-07-31 10:28:05 -04:00
|
|
|
.IP \(bu 2
|
2023-03-27 06:08:54 -04:00
|
|
|
\fBnew-selection\fP: If \fB\fCkeep-selection\fR is set, this allows you to override
|
|
|
|
the selected entry (absolute position).
|
2022-07-09 08:12:28 -04:00
|
|
|
.IP \(bu 2
|
2023-03-27 06:08:54 -04:00
|
|
|
\fBdata\fP: Passed data to the next execution of the script via
|
|
|
|
\fBROFI_DATA\fP\&.
|
2022-06-03 13:48:34 -04:00
|
|
|
.IP \(bu 2
|
2023-03-27 06:08:54 -04:00
|
|
|
\fBtheme\fP: Small theme snippet to f.e. change the background color of
|
|
|
|
a widget.
|
2021-05-02 14:01:03 -04:00
|
|
|
|
2021-06-15 14:10:04 -04:00
|
|
|
.RE
|
|
|
|
|
2023-11-10 08:41:48 -05:00
|
|
|
.PP
|
|
|
|
The \fBtheme\fP 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 15:34:14 -05:00
|
|
|
.SH Parsing row options
|
|
|
|
.PP
|
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 15:34:14 -05:00
|
|
|
|
|
|
|
.PP
|
|
|
|
For example:
|
|
|
|
|
|
|
|
.PP
|
|
|
|
.RS
|
|
|
|
|
|
|
|
.nf
|
2022-10-22 05:03:11 -04:00
|
|
|
echo -en "aap\\0icon\\x1ffolder\\n"
|
2020-02-02 15:34:14 -05:00
|
|
|
|
|
|
|
.fi
|
|
|
|
.RE
|
|
|
|
|
|
|
|
.PP
|
|
|
|
The following options are supported:
|
2021-06-15 14:10:04 -04:00
|
|
|
|
|
|
|
.RS
|
2020-02-02 15:34:14 -05:00
|
|
|
.IP \(bu 2
|
|
|
|
\fBicon\fP: Set the icon for that row.
|
|
|
|
.IP \(bu 2
|
2023-11-06 14:02:48 -05:00
|
|
|
\fBdisplay\fP: Replace the displayed string. (Original string will still be used for searching)
|
|
|
|
.IP \(bu 2
|
2020-02-02 15:34:14 -05:00
|
|
|
\fBmeta\fP: Specify invisible search terms.
|
|
|
|
.IP \(bu 2
|
|
|
|
\fBnonselectable\fP: If true the row cannot activated.
|
2020-05-24 13:09:06 -04:00
|
|
|
.IP \(bu 2
|
2023-03-27 06:08:54 -04:00
|
|
|
\fBinfo\fP: Info that, on selection, gets placed in the \fB\fCROFI_INFO\fR
|
|
|
|
environment variable. This entry does not get searched.
|
2023-01-08 06:10:40 -05:00
|
|
|
.IP \(bu 2
|
|
|
|
\fBurgent\fP: Set urgent flag on entry (true/false)
|
|
|
|
.IP \(bu 2
|
|
|
|
\fBactive\fP: Set active flag on entry (true/false)
|
2020-05-24 13:09:06 -04:00
|
|
|
|
2021-06-15 14:10:04 -04:00
|
|
|
.RE
|
|
|
|
|
2020-05-24 13:09:06 -04:00
|
|
|
.PP
|
|
|
|
multiple entries can be passed using the \fB\fC\\x1f\fR separator.
|
|
|
|
|
|
|
|
.PP
|
|
|
|
.RS
|
|
|
|
|
|
|
|
.nf
|
2022-10-22 05:03:11 -04:00
|
|
|
echo -en "aap\\0icon\\x1ffolder\\x1finfo\\x1ftest\\n"
|
2020-05-24 13:09:06 -04:00
|
|
|
|
|
|
|
.fi
|
|
|
|
.RE
|
2020-02-02 15:34:14 -05:00
|
|
|
|
2021-03-10 14:45:53 -05:00
|
|
|
.SH Executing external program
|
|
|
|
.PP
|
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
|
|
|
|
|
|
|
.PP
|
|
|
|
In bash the best way to do this is using \fB\fCcoproc\fR\&.
|
|
|
|
|
|
|
|
.PP
|
|
|
|
.RS
|
|
|
|
|
|
|
|
.nf
|
2022-10-22 05:03:11 -04:00
|
|
|
coproc ( myApp > /dev/null 2>&1 )
|
2021-03-10 14:45:53 -05:00
|
|
|
|
|
|
|
.fi
|
|
|
|
.RE
|
|
|
|
|
2020-09-25 07:29:03 -04:00
|
|
|
.SH DASH shell
|
|
|
|
.PP
|
2023-03-27 06:08:54 -04:00
|
|
|
If you use the \fB\fCdash\fR shell for your script, take special care with how dash
|
|
|
|
handles escaped values for the separators. See issue #1201 on github.
|
2020-09-25 07:29:03 -04:00
|
|
|
|
2023-03-26 07:57:50 -04:00
|
|
|
.SH Script locations
|
|
|
|
.PP
|
|
|
|
To specify a script there are the following options:
|
|
|
|
|
|
|
|
.RS
|
|
|
|
.IP \(bu 2
|
|
|
|
Specify an absolute path to the script.
|
|
|
|
.IP \(bu 2
|
|
|
|
The script is executable and located in your $PATH
|
|
|
|
|
|
|
|
.RE
|
|
|
|
|
|
|
|
.PP
|
|
|
|
Scripts located in the following location are loaded on startup:
|
|
|
|
|
|
|
|
.RS
|
|
|
|
.IP \(bu 2
|
2023-03-27 06:08:54 -04:00
|
|
|
The script is in \fB\fC$XDG_CONFIG_PATH/rofi/scripts/\fR, this is usually
|
|
|
|
\fB\fC~/.config/rofi/scripts/\fR\&.
|
2023-03-26 07:57:50 -04:00
|
|
|
|
|
|
|
.RE
|
|
|
|
|
2020-02-02 15:34:14 -05:00
|
|
|
.SH SEE ALSO
|
|
|
|
.PP
|
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 15:34:14 -05:00
|
|
|
|
|
|
|
.SH AUTHOR
|
|
|
|
.PP
|
2022-10-22 05:03:11 -04:00
|
|
|
Qball Cow qball@gmpclient.org
|
|
|
|
\[la]mailto:qball@gmpclient.org\[ra]
|
2020-02-02 15:34:14 -05:00
|
|
|
|
|
|
|
.PP
|
2022-10-22 05:03:11 -04:00
|
|
|
Rasmus Steinke rasi@xssn.at
|
|
|
|
\[la]mailto:rasi@xssn.at\[ra]
|
2020-02-02 15:34:14 -05:00
|
|
|
|
|
|
|
.PP
|
2022-10-22 05:03:11 -04:00
|
|
|
Morgane Glidic sardemff7+rofi@sardemff7.net
|
|
|
|
\[la]mailto:sardemff7+rofi@sardemff7.net\[ra]
|
2020-02-02 15:34:14 -05:00
|
|
|
|
|
|
|
.PP
|
2022-10-22 05:03:11 -04:00
|
|
|
Original code based on work by: Sean Pringle sean.pringle@gmail.com
|
|
|
|
\[la]mailto:sean.pringle@gmail.com\[ra]
|
2020-02-02 15:34:14 -05:00
|
|
|
|
|
|
|
.PP
|
|
|
|
For a full list of authors, check the AUTHORS file.
|