diff options
| author | srdusr <[email protected]> | 2025-01-17 23:01:00 +0200 |
|---|---|---|
| committer | srdusr <[email protected]> | 2025-01-17 23:01:00 +0200 |
| commit | 6c1dfe191843ad56aaa0381e5645ad9e74c38b8b (patch) | |
| tree | 427d72a55eba93b2f0da299342c12bd3c61df1d6 /crates/config/src/engine | |
| parent | 3d73ed0f057a555ded67ad58dbe02b36cd4d2d1f (diff) | |
| download | srdwm-6c1dfe191843ad56aaa0381e5645ad9e74c38b8b.tar.gz srdwm-6c1dfe191843ad56aaa0381e5645ad9e74c38b8b.zip | |
Accumulate config engine, build metadata, and doc updates
Remaining files from the backlog: Lua config engine
additions (general/register/support/window), workspace Cargo.toml/
Cargo.lock churn from the new dependencies added elsewhere in this
sweep, srdwm/main.rs wiring, and docs (DEFAULTS.md plus a new
SESSION_HANDOFF.md written mid-session for continuity across a restart
- see that file's own header for what it is and isn't).
Diffstat (limited to 'crates/config/src/engine')
| -rw-r--r-- | crates/config/src/engine/general.rs | 20 | ||||
| -rw-r--r-- | crates/config/src/engine/register.rs | 2 | ||||
| -rw-r--r-- | crates/config/src/engine/support.rs | 2 | ||||
| -rw-r--r-- | crates/config/src/engine/window.rs | 14 |
4 files changed, 37 insertions, 1 deletions
diff --git a/crates/config/src/engine/general.rs b/crates/config/src/engine/general.rs index 96ea4d3..98cfebe 100644 --- a/crates/config/src/engine/general.rs +++ b/crates/config/src/engine/general.rs @@ -128,7 +128,8 @@ impl Engine { /// class_regex = "...", instance = "..." }, { floating = true, /// workspace = 2, x = .., y = .., width = .., height = .., /// decorated = false, border_color = {r,g,b}, border_width = 2, - /// maximized = true, opacity = 0.9 })`. At least one matcher field is + /// corner_radius = 10, maximized = true, opacity = 0.9 })`. At least + /// one matcher field is /// required; unmatched rules apply nothing. /// /// `title`/`class` are plain substring/exact match, cheap and cover @@ -182,6 +183,7 @@ impl Engine { decorated: actions.get("decorated")?, border_color, border_width: actions.get("border_width")?, + corner_radius: actions.get("corner_radius")?, pinned: actions.get("pinned")?, opacity: actions.get("opacity")?, resize_margin: actions.get("resize_margin")?, @@ -217,6 +219,22 @@ impl Engine { })?) } + /// Sets an environment variable in srdwm's own process - `std::process:: + /// Command` inherits the parent's environment by default (`fn_spawn` + /// above never overrides that), so anything set here is visible to + /// every process `srd.spawn` starts from this point on, and to their own + /// children in turn. Hyprland's `env = NAME,VALUE` works the same way + /// (sets it in its own process before forking anything), which is the + /// mechanism a ported `env.conf` needs - there is no per-spawn + /// equivalent that would let one client see a variable no other client + /// does, so this is deliberately global and process-wide, not scoped. + pub(super) fn fn_setenv(&self) -> Result<mlua::Function<'_>> { + Ok(self.lua.create_function(move |_, (name, value): (String, String)| { + std::env::set_var(&name, &value); + Ok(()) + })?) + } + pub(super) fn fn_quit(&self) -> Result<mlua::Function<'_>> { let state = self.state.clone(); Ok(self.lua.create_function(move |_, ()| { diff --git a/crates/config/src/engine/register.rs b/crates/config/src/engine/register.rs index abe919b..0cf64bc 100644 --- a/crates/config/src/engine/register.rs +++ b/crates/config/src/engine/register.rs @@ -17,6 +17,7 @@ impl Engine { srd.set("rule", self.fn_rule()?)?; srd.set("load", self.fn_load()?)?; srd.set("spawn", self.fn_spawn()?)?; + srd.set("setenv", self.fn_setenv()?)?; srd.set("notify", self.fn_notify()?)?; srd.set("quit", self.fn_quit()?)?; srd.set("reload", self.fn_reload()?)?; @@ -44,6 +45,7 @@ impl Engine { window.set("set_decorations", self.fn_window_set_decorations()?)?; window.set("set_border_color", self.fn_window_set_border_color()?)?; window.set("set_border_width", self.fn_window_set_border_width()?)?; + window.set("set_corner_radius", self.fn_window_set_corner_radius()?)?; window.set("set_opacity", self.fn_window_set_opacity()?)?; window.set("set_resize_margin", self.fn_window_set_resize_margin()?)?; window.set("set_floating", self.fn_window_set_floating()?)?; diff --git a/crates/config/src/engine/support.rs b/crates/config/src/engine/support.rs index 9346499..0f83885 100644 --- a/crates/config/src/engine/support.rs +++ b/crates/config/src/engine/support.rs @@ -82,6 +82,7 @@ pub(super) fn validate(s: &SharedState) -> Vec<String> { check_range("layout.floating.gaps.outer", 0.0, 100.0); check_range("general.border_width", 0.0, 20.0); check_range("theme.decorations.border.width", 0.0, 20.0); + check_range("theme.decorations.border.radius", 0.0, 100.0); check_range("general.animation_duration", 0.0, 1000.0); check_range("general.resize_margin", 1.0, 50.0); check_range("performance.max_fps", 30.0, 240.0); @@ -242,6 +243,7 @@ pub(super) fn default_config() -> HashMap<String, ConfigValue> { set("theme.colors.success", String("#a3be8c".into())); set("theme.decorations.border.width", Number(2.0)); + set("theme.decorations.border.radius", Number(6.0)); set("theme.decorations.border.active_color", String("#88c0d0".into())); set("theme.decorations.border.inactive_color", String("#2e3440".into())); set("theme.decorations.border.focused_style", String("solid".into())); diff --git a/crates/config/src/engine/window.rs b/crates/config/src/engine/window.rs index a7e6bf3..61e7b89 100644 --- a/crates/config/src/engine/window.rs +++ b/crates/config/src/engine/window.rs @@ -139,6 +139,20 @@ impl Engine { })?) } + pub(super) fn fn_window_set_corner_radius(&self) -> Result<mlua::Function<'_>> { + let state = self.state.clone(); + Ok(self.lua.create_function(move |_, radius: u32| { + let wm = state.borrow().wm.clone(); + let mut wm = wm.borrow_mut(); + if let Some(id) = wm.focused_id() { + if let Some(w) = wm.window_mut(id) { + w.corner_radius = radius; + } + } + Ok(()) + })?) + } + pub(super) fn fn_window_set_opacity(&self) -> Result<mlua::Function<'_>> { let state = self.state.clone(); Ok(self.lua.create_function(move |_, opacity: f32| { |