Crate miracle_plugin

Crate miracle_plugin 

Source
Expand description

§miracle-plugin

A Rust SDK for writing miracle-wm plugins.

Miracle’s plugin system runs each plugin as a WebAssembly module. This crate provides idiomatic Rust types and traits that map to the compositor’s C ABI, so you can write plugins without touching raw FFI.

§Quick start

Create a new library crate and add miracle-plugin as a dependency:

cargo new --lib my-plugin
cd my-plugin
cargo add miracle-plugin

Set the crate type to cdylib in Cargo.toml:

# Cargo.toml
[lib]
crate-type = ["cdylib"]

If you would like to configure from your plugin, enable the configure feature, e.g.:

# Cargo.toml
[dependencies]
miracle-plugin = { version = "0.0.5", features = ["configure"]}

Add the wasm32-wasip1 target if you haven’t already:

rustup target add wasm32-wasip1

Implement the plugin::Plugin trait and register your type with the miracle_plugin! macro:

use miracle_plugin::plugin::Plugin;

#[derive(Default)]
struct MyPlugin;

impl Plugin for MyPlugin {
    // Your plugin implementation here.
}

miracle_plugin::miracle_plugin!(MyPlugin);

Build the plugin as a .wasm module:

cargo build --target wasm32-wasip1 --release

The compiled .wasm file will be at target/wasm32-wasip1/release/my_plugin.wasm.

§Modules

Re-exports§

pub use config::BindingAction;
pub use config::Key;
pub use config::Modifier;
pub use plugin::get_active_workspace;
pub use plugin::get_output_at;
pub use plugin::get_outputs;
pub use plugin::get_userdata_json;
pub use plugin::managed_windows;
pub use plugin::num_outputs;
pub use plugin::queue_custom_animation;
pub use plugin::request_workspace;

Modules§

animation
application
config
Configuration types for the plugin configure() hook.
container
core
input
output
placement
plugin
window
workspace

Macros§

miracle_plugin
Registers a type as a miracle-wm plugin.