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-pluginSet 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-wasip1Implement 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 --releaseThe compiled .wasm file will be at
target/wasm32-wasip1/release/my_plugin.wasm.
§Modules
| Module | Contents |
|---|---|
plugin | plugin::Plugin trait, miracle_plugin! macro, helper functions |
window | window::WindowInfo, window::PluginWindow, window-state enums |
placement | placement::Placement |
animation | animation::AnimationFrameData, animation::AnimationFrameResult |
input | input::KeyboardEvent, input::PointerEvent, modifier/button flags |
core | Geometric primitives: core::Rect, core::Point, core::Size, core::Rectangle |
container | container::Container, [container::ContainerType], container::LayoutScheme |
workspace | workspace::Workspace |
output | output::Output |
application | application::ApplicationInfo |
config | config::Configuration and all supporting types (config::Modifier, config::Key, config::BindingAction, …) |
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.