rofi-mode
A high-level Rust library for creating Rofi plugins and custom modes
Getting started
First of all,
create a new library with cargo new --lib my_awesome_plugin
and add these lines to the Cargo.toml:
[]
= ["cdylib"]
That will force Cargo to generate your library as a .so file,
which is what Rofi loads its plugins from.
Then, add this crate as a dependency using the following command:
Now in your lib.rs,
create a struct and implement the Mode trait for it.
For example, here is a no-op mode with no entries:
;
You then need to export your mode to Rofi via the export_mode! macro:
export_mode!;
Build your library using cargo build
then copy the resulting dylib file
(e.g. /target/debug/libmy_awesome_plugin.so)
into /lib/rofi
so that Rofi will pick up on it
when it starts up
(alternatively,
you can set the ROFI_PLUGIN_PATH environment variable
to the directory your .so file is in).
You can then run your mode from Rofi's command line:
Build with RUSTFLAGS="--cfg rofi_next" to support unreleased Rofi versions,
and drop support for released Rofi versions.
This will turn on semver-exempt features, so use with caution.
Examples
- See examples/basic for a basic example of a non-trivial Rofi mode, which allows the user to add to the list of entries by writing in the Rofi box.
- See examples/file-browser for a Rofi mode implementing a simple file browser.
License: MIT