Function add_window_rule

Source
pub fn add_window_rule(for_all: impl FnMut(WindowHandle) + Send + 'static)
Expand description

Adds a window rule.

Instead of using a declarative window rule system with match conditions, you supply a closure that acts on a newly opened window. You can use standard if statements and apply properties using the same methods that are used everywhere else in this API.

Note: this function is special in that if it is called, Pinnacle will wait for the provided closure to finish running before it sends windows an initial configure event. Do not block here. At best, short blocks will increase the time it takes for a window to open. At worst, a complete deadlock will prevent windows from opening at all.

ยงExamples

window::add_window_rule(|window| {
    // Make Alacritty always open on the "Terminal" tag
    if window.app_id() == "Alacritty" {
        window.set_tag(&tag::get("Terminal").unwrap(), true);
    }

    // Make all windows use client-side decorations
    window.set_decoration_mode(DecorationMode::ClientSide);
});