From 821ca803194bb7238d514487d9a8cb302a0fba9e Mon Sep 17 00:00:00 2001 From: moorgrove Date: Tue, 25 Aug 2026 15:40:44 +0200 Subject: [PATCH 1/2] Let themes set Hyprland rounding and shadow through colors.toml A theme installed with omarchy theme install has its .lua stripped for security (#7884), so decoration.rounding and shadow can never come from a hand-written hyprland.lua, only border colors through colors.toml. Add a value template helper next to the existing gradient ones and use it to render those settings from plain colors.toml keys, falling back to Omarchy's current defaults when a theme leaves them unset. --- bin/omarchy-theme-set-templates | 13 ++++++++----- default/themed/hyprland.lua.tpl | 14 ++++++++++++++ docs/theming.md | 34 +++++++++++++++++++++++++++++++++ test/cli | 28 +++++++++++++++++++++++++++ 4 files changed, 84 insertions(+), 5 deletions(-) diff --git a/bin/omarchy-theme-set-templates b/bin/omarchy-theme-set-templates index de4d599137ec..f4645dea60c3 100755 --- a/bin/omarchy-theme-set-templates +++ b/bin/omarchy-theme-set-templates @@ -251,7 +251,7 @@ add_mix_values() { done } -add_gradient_function_value() { +add_template_function_value() { local token="$1" local content fn key fallback value @@ -269,6 +269,9 @@ add_gradient_function_value() { shell_gradient) value=$(shell_gradient_value "$key" "$fallback") ;; + value) + value=$(resolve_theme_ref "$key" "$fallback") + ;; *) return ;; @@ -277,7 +280,7 @@ add_gradient_function_value() { printf 's|%s|%s|g\n' "$token" "$value" >>"$sed_script" } -add_gradient_function_values() { +add_template_function_values() { local tpl token local -A seen=() @@ -285,8 +288,8 @@ add_gradient_function_values() { while IFS= read -r token; do [[ -n ${seen[$token]:-} ]] && continue seen[$token]=1 - add_gradient_function_value "$token" - done < <(grep -hEo '\{\{[[:space:]]*(hypr_gradient|gradient_start|shell_gradient)[[:space:]]+[^}]+[[:space:]]*\}\}' "$tpl" 2>/dev/null || true) + add_template_function_value "$token" + done < <(grep -hEo '\{\{[[:space:]]*(hypr_gradient|gradient_start|shell_gradient|value)[[:space:]]+[^}]+[[:space:]]*\}\}' "$tpl" 2>/dev/null || true) done } @@ -385,7 +388,7 @@ if [[ -f $COLORS_FILE ]]; then done add_mix_values - add_gradient_function_values + add_template_function_values # Process user templates first, then built-in templates (user overrides built-in) for tpl in "${template_files[@]}"; do diff --git a/default/themed/hyprland.lua.tpl b/default/themed/hyprland.lua.tpl index 1a2d6d1a511d..078626e3b6f3 100644 --- a/default/themed/hyprland.lua.tpl +++ b/default/themed/hyprland.lua.tpl @@ -15,4 +15,18 @@ hl.config({ border_inactive = inactive_border_color, }, }, + + decoration = { + rounding = {{ value hyprland_rounding 0 }}, + rounding_power = {{ value hyprland_rounding_power 2 }}, + + shadow = { + enabled = {{ value hyprland_shadow_enabled false }}, + range = {{ value hyprland_shadow_range 4 }}, + render_power = {{ value hyprland_shadow_render_power 3 }}, + offset = "{{ value hyprland_shadow_offset 0 0 }}", + color = "{{ value hyprland_shadow_color rgba(1a1a1aee) }}", + color_inactive = "{{ value hyprland_shadow_color_inactive rgba(1a1a1aee) }}", + }, + }, }) diff --git a/docs/theming.md b/docs/theming.md index 2399a7b0be2f..dd3bdd2a8658 100644 --- a/docs/theming.md +++ b/docs/theming.md @@ -175,6 +175,20 @@ The second argument is a fallback. For example, `hyprland_active_border` if the theme defines it; otherwise use `accent`. The helper does not choose the first color unless you use `gradient_start`. +### Value helper + +`{{ value key fallback }}` resolves a plain (non-color) `colors.toml` key with +a fallback, the same way the gradient helpers do: + +```text +{{ value hyprland_rounding 0 }} +``` + +If the theme defines `hyprland_rounding`, that value is used; otherwise the +fallback is tried as another palette key first, then used literally (`0` +here). This is how optional numeric/boolean settings, like the Hyprland +decoration keys below, stay valid Lua even when a theme never mentions them. + ## `shell.toml` `shell.toml` contains shell surface roles, control states, spacing, typography, @@ -371,6 +385,26 @@ For a gradient it renders: local active_border_color = { colors = { "rgba(33ccffee)", "rgba(00ff99ee)" }, angle = 45 } ``` +`hyprland.lua.tpl` also renders a `decoration` block from optional `colors.toml` +keys, using the `value` helper so a theme that never sets them still gets valid +Lua matching Omarchy's own defaults: + +| `colors.toml` key | Default | `decoration` field | +|---|---|---| +| `hyprland_rounding` | `0` | `rounding` | +| `hyprland_rounding_power` | `2` | `rounding_power` | +| `hyprland_shadow_enabled` | `false` | `shadow.enabled` | +| `hyprland_shadow_range` | `4` | `shadow.range` | +| `hyprland_shadow_render_power` | `3` | `shadow.render_power` | +| `hyprland_shadow_offset` | `0 0` | `shadow.offset` | +| `hyprland_shadow_color` | `rgba(1a1a1aee)` | `shadow.color` | +| `hyprland_shadow_color_inactive` | `rgba(1a1a1aee)` | `shadow.color_inactive` | + +This is what lets a theme installed from a git repo (see +[What an installed theme may not ship](#what-an-installed-theme-may-not-ship)) +still ship rounded corners and a window shadow, without shipping a +hand-written `hyprland.lua` that the staging filter would drop. + ## Adding or overriding theme files - Add palette values to `themes//colors.toml`. diff --git a/test/cli b/test/cli index 80b981d5cd2c..b33d2f808a7b 100755 --- a/test/cli +++ b/test/cli @@ -257,6 +257,14 @@ cat >"$NEXT_THEME/colors.toml" <<'EOF' mode = "light" accent = "#336699" hyprland_active_border = "rgba(010203ee) rgba(040506ee) 45deg" +hyprland_rounding = "6" +hyprland_rounding_power = "3" +hyprland_shadow_enabled = "true" +hyprland_shadow_range = "22" +hyprland_shadow_render_power = "3" +hyprland_shadow_offset = "0 6" +hyprland_shadow_color = "rgba(00000099)" +hyprland_shadow_color_inactive = "rgba(00000055)" background = "#000000" dark_background = "#010101" darker_background = "#020202" @@ -304,6 +312,9 @@ shell-gradient={{ shell_gradient hyprland_active_border accent }} fallback-hypr={{ hypr_gradient missing accent }} fallback-shell={{ gradient_start missing accent }} fallback-shell-gradient={{ shell_gradient missing accent }} +value={{ value hyprland_rounding 0 }} +fallback-value={{ value missing 0 }} +fallback-value-key={{ value missing accent }} EOF cat >"$USER_THEMED/alias-test.txt.tpl" <<'EOF' @@ -455,6 +466,23 @@ grep -qx 'fallback-shell=#336699' "$NEXT_THEME/gradient-test.txt" || fail "theme grep -qx 'fallback-shell-gradient=#336699' "$NEXT_THEME/gradient-test.txt" || fail "theme template shell_gradient fallback works" pass "theme template gradient helpers work" +grep -qx 'value=6' "$NEXT_THEME/gradient-test.txt" || fail "theme template value helper works" +grep -qx 'fallback-value=0' "$NEXT_THEME/gradient-test.txt" || fail "theme template value helper literal fallback works" +grep -qx 'fallback-value-key=#336699' "$NEXT_THEME/gradient-test.txt" || fail "theme template value helper key fallback works" +pass "theme template value helper works" + +grep -Fq 'rounding = 6,' "$NEXT_THEME/hyprland.lua" || fail "theme template renders custom hyprland rounding" +grep -Fq 'rounding_power = 3,' "$NEXT_THEME/hyprland.lua" || fail "theme template renders custom hyprland rounding power" +grep -Fq 'enabled = true,' "$NEXT_THEME/hyprland.lua" || fail "theme template renders custom hyprland shadow enabled" +grep -Fq 'range = 22,' "$NEXT_THEME/hyprland.lua" || fail "theme template renders custom hyprland shadow range" +grep -Fq 'offset = "0 6",' "$NEXT_THEME/hyprland.lua" || fail "theme template renders custom hyprland shadow offset" +grep -Fq 'color = "rgba(00000099)",' "$NEXT_THEME/hyprland.lua" || fail "theme template renders custom hyprland shadow color" +pass "theme template renders custom hyprland decoration settings" + +grep -Fq 'rounding = 0,' "$LEGACY_NEXT_THEME/hyprland.lua" || fail "theme without decoration keys falls back to default rounding" +grep -Fq 'enabled = false,' "$LEGACY_NEXT_THEME/hyprland.lua" || fail "theme without decoration keys falls back to shadow disabled" +pass "theme without decoration keys falls back to Omarchy's default look'n'feel" + awk ' /^\[lock\]$/ { in_lock = 1; next } /^\[/ { in_lock = 0 } From 12afc2282a0fa6a7be05c34882f3345a44d6f16f Mon Sep 17 00:00:00 2001 From: moorgrove Date: Tue, 25 Aug 2026 16:13:40 +0200 Subject: [PATCH 2/2] Unwrap new theming.md prose to single lines per AGENTS.md style --- docs/theming.md | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/docs/theming.md b/docs/theming.md index dd3bdd2a8658..bca5d639d371 100644 --- a/docs/theming.md +++ b/docs/theming.md @@ -177,17 +177,13 @@ The helper does not choose the first color unless you use `gradient_start`. ### Value helper -`{{ value key fallback }}` resolves a plain (non-color) `colors.toml` key with -a fallback, the same way the gradient helpers do: +`{{ value key fallback }}` resolves a plain (non-color) `colors.toml` key with a fallback, the same way the gradient helpers do: ```text {{ value hyprland_rounding 0 }} ``` -If the theme defines `hyprland_rounding`, that value is used; otherwise the -fallback is tried as another palette key first, then used literally (`0` -here). This is how optional numeric/boolean settings, like the Hyprland -decoration keys below, stay valid Lua even when a theme never mentions them. +If the theme defines `hyprland_rounding`, that value is used; otherwise the fallback is tried as another palette key first, then used literally (`0` here). This is how optional numeric/boolean settings, like the Hyprland decoration keys below, stay valid Lua even when a theme never mentions them. ## `shell.toml` @@ -385,9 +381,7 @@ For a gradient it renders: local active_border_color = { colors = { "rgba(33ccffee)", "rgba(00ff99ee)" }, angle = 45 } ``` -`hyprland.lua.tpl` also renders a `decoration` block from optional `colors.toml` -keys, using the `value` helper so a theme that never sets them still gets valid -Lua matching Omarchy's own defaults: +`hyprland.lua.tpl` also renders a `decoration` block from optional `colors.toml` keys, using the `value` helper so a theme that never sets them still gets valid Lua matching Omarchy's own defaults: | `colors.toml` key | Default | `decoration` field | |---|---|---| @@ -400,10 +394,7 @@ Lua matching Omarchy's own defaults: | `hyprland_shadow_color` | `rgba(1a1a1aee)` | `shadow.color` | | `hyprland_shadow_color_inactive` | `rgba(1a1a1aee)` | `shadow.color_inactive` | -This is what lets a theme installed from a git repo (see -[What an installed theme may not ship](#what-an-installed-theme-may-not-ship)) -still ship rounded corners and a window shadow, without shipping a -hand-written `hyprland.lua` that the staging filter would drop. +This is what lets a theme installed from a git repo (see [What an installed theme may not ship](#what-an-installed-theme-may-not-ship)) still ship rounded corners and a window shadow, without shipping a hand-written `hyprland.lua` that the staging filter would drop. ## Adding or overriding theme files