diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-11-14 11:33:08 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-11-14 12:05:30 +0300 |
| commit | 1a0612cbfd0abee0796efa86470226686ae78f21 (patch) | |
| tree | 809037c94948e0107614f5d01564712512468332 /niri-config | |
| parent | fbbd3ba349223f7cc4ebeaa397f7c48e880a7c30 (diff) | |
| download | niri-1a0612cbfd0abee0796efa86470226686ae78f21.tar.gz niri-1a0612cbfd0abee0796efa86470226686ae78f21.tar.bz2 niri-1a0612cbfd0abee0796efa86470226686ae78f21.zip | |
Implement layer rules: opacity and block-out-from
Diffstat (limited to 'niri-config')
| -rw-r--r-- | niri-config/src/layer_rule.rs | 22 | ||||
| -rw-r--r-- | niri-config/src/lib.rs | 21 |
2 files changed, 43 insertions, 0 deletions
diff --git a/niri-config/src/layer_rule.rs b/niri-config/src/layer_rule.rs new file mode 100644 index 00000000..dc6fbd8d --- /dev/null +++ b/niri-config/src/layer_rule.rs @@ -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>, +} diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs index 7fa4f527..5c5f2cf7 100644 --- a/niri-config/src/lib.rs +++ b/niri-config/src/lib.rs @@ -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