miracle-plugin 0.0.3

Rust bindings for the miracle-wm plugin API
docs.rs failed to build miracle-plugin-0.0.3
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: miracle-plugin-0.0.1

miracle-plugin-rs

This package provides a pleasant API for writing plugins for miracle-wm. Miracle's plugin system uses WebAssembly

Setup

sudo apt-get install -y libmircore-dev clang libclang-dev
rustup target add wasm32-wasip1

Building

cargo build --target wasm32-wasip1 --release

Usage

First, make sure that you have the Mir and Rust dependencies installed:

sudo apt-get install -y libmircore-dev clang libclang-dev
rustup target add wasm32-wasip1

Next, add miracle-plugin as a dependency of your crate:

cargo add miracle-plugin

Then, author your plugin (the following is a toy example):

// lib.rs

// First, declare your plugin.
struct MyVeryCoolMiraclePlugin;

impl Plugin for MyVeryCoolMiraclePlugin {
    fn place_new_window(&mut self, info: &WindowInfo) -> Option<Placement> {
        if info.window_type != WindowType::Normal && info.window_type != WindowType::Freestyle {
            return None;
        }

        if info.state == WindowState::Attached {
            return None;
        }

        Some(Placement::Freestyle(FreestylePlacement {
            top_left: Point::new(100, 100),
            depth_layer: DepthLayer::Application,
            workspace: None,
            size: Size::new(500, 500),
            transform: Mat4::IDENTITY,
            alpha: 1.0,
            movable: false,
            resizable: false
        }))
    }
    
    // And many more hooks...!
}

// Then, register it with Miracle.
miracle_plugin!(Miri);

Next, build your plugin with:

cargo build --target wasm32-wasip1
# or
cargo build --target wasm32-wasip1 --release

Finally, modify your Miracle config to load the plugin:

# ~/.config/miracle-wm/config.yaml

plugins:
    - path: /path/to/myplugin.wasm