mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-24 02:01:18 +07:00
Implement layer rules: opacity and block-out-from
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
use crate::{BlockOutFrom, RegexEq};
|
||||
|
||||
#[derive(knuffel::Decode, Debug, Default, Clone, PartialEq)]
|
||||
pub struct LayerRule {
|
||||
#[knuffel(children(name = "match"))]
|
||||
pub matches: Vec<Match>,
|
||||
#[knuffel(children(name = "exclude"))]
|
||||
pub excludes: Vec<Match>,
|
||||
|
||||
#[knuffel(child, unwrap(argument))]
|
||||
pub opacity: Option<f32>,
|
||||
#[knuffel(child, unwrap(argument))]
|
||||
pub block_out_from: Option<BlockOutFrom>,
|
||||
}
|
||||
|
||||
#[derive(knuffel::Decode, Debug, Default, Clone, PartialEq)]
|
||||
pub struct Match {
|
||||
#[knuffel(property, str)]
|
||||
pub namespace: Option<RegexEq>,
|
||||
#[knuffel(property)]
|
||||
pub at_startup: Option<bool>,
|
||||
}
|
||||
@@ -10,6 +10,7 @@ use std::time::Duration;
|
||||
use bitflags::bitflags;
|
||||
use knuffel::errors::DecodeError;
|
||||
use knuffel::Decode as _;
|
||||
use layer_rule::LayerRule;
|
||||
use miette::{miette, Context, IntoDiagnostic, NarratableReportHandler};
|
||||
use niri_ipc::{ConfiguredMode, LayoutSwitchTarget, SizeChange, Transform, WorkspaceReferenceArg};
|
||||
use smithay::backend::renderer::Color32F;
|
||||
@@ -20,6 +21,8 @@ use smithay::reexports::input;
|
||||
|
||||
pub const DEFAULT_BACKGROUND_COLOR: Color = Color::from_array_unpremul([0.2, 0.2, 0.2, 1.]);
|
||||
|
||||
pub mod layer_rule;
|
||||
|
||||
mod utils;
|
||||
pub use utils::RegexEq;
|
||||
|
||||
@@ -53,6 +56,8 @@ pub struct Config {
|
||||
pub environment: Environment,
|
||||
#[knuffel(children(name = "window-rule"))]
|
||||
pub window_rules: Vec<WindowRule>,
|
||||
#[knuffel(children(name = "layer-rule"))]
|
||||
pub layer_rules: Vec<LayerRule>,
|
||||
#[knuffel(child, default)]
|
||||
pub binds: Binds,
|
||||
#[knuffel(child, default)]
|
||||
@@ -3119,6 +3124,11 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
layer-rule {
|
||||
match namespace="^notifications$"
|
||||
block-out-from "screencast"
|
||||
}
|
||||
|
||||
binds {
|
||||
Mod+T allow-when-locked=true { spawn "alacritty"; }
|
||||
Mod+Q { close-window; }
|
||||
@@ -3391,6 +3401,17 @@ mod tests {
|
||||
},
|
||||
..Default::default()
|
||||
}],
|
||||
layer_rules: vec![
|
||||
LayerRule {
|
||||
matches: vec![layer_rule::Match {
|
||||
namespace: Some(RegexEq::from_str("^notifications$").unwrap()),
|
||||
at_startup: None,
|
||||
}],
|
||||
excludes: vec![],
|
||||
opacity: None,
|
||||
block_out_from: Some(BlockOutFrom::Screencast),
|
||||
}
|
||||
],
|
||||
workspaces: vec![
|
||||
Workspace {
|
||||
name: WorkspaceName("workspace-1".to_string()),
|
||||
|
||||
Reference in New Issue
Block a user