Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions bin/omarchy-theme-set-templates
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ resolve_theme_ref() {
local ref="$1"
local fallback="${2:-}"

if [[ -n ${THEME_COLORS[$ref]+_} ]]; then
if [[ -n $ref && -n ${THEME_COLORS[$ref]:-} ]]; then
REPLY="${THEME_COLORS[$ref]}"
elif [[ -n $fallback && -n ${THEME_COLORS[$fallback]+_} ]]; then
elif [[ -n $fallback && -n ${THEME_COLORS[$fallback]:-} ]]; then
REPLY="${THEME_COLORS[$fallback]}"
elif [[ -n $fallback ]]; then
REPLY="$fallback"
Expand All @@ -58,7 +58,8 @@ resolve_theme_ref() {

resolve_gradient_color() {
trim "$1"
if [[ -n ${THEME_COLORS[$REPLY]+_} ]]; then
[[ -n $REPLY ]] || return
if [[ -n ${THEME_COLORS[$REPLY]:-} ]]; then
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
REPLY="${THEME_COLORS[$REPLY]}"
fi
}
Expand Down
33 changes: 33 additions & 0 deletions test/shell.d/theme-templates-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,36 @@ printf 'accent = "nope"\nbackground = "#1a1b26"\nforeground = "#a9b1d6"\n' >"$st
set_icons
[[ ! -e $state/icons/omawrite.svg && ! -L $apps/omawrite.svg ]] || fail "a theme that can't draw app icons brings the packaged ones back"
pass "a theme that can't draw app icons brings the packaged ones back"

# Explicitly empty palette keys fall back instead of resolving to empty strings.
empty_home="$test_tmp/empty-home"
empty_next="$empty_home/.local/state/omarchy/current/next-theme"
empty_themed="$empty_home/.config/omarchy/themed"
mkdir -p "$empty_next" "$empty_themed"
cat >"$empty_next/colors.toml" <<'EOF'
background = "#111111"
foreground = "#eeeeee"
accent = ""
blue = "#336699"
hyprland_active_border = ""
EOF
cat >"$empty_themed/empty-fallback.txt.tpl" <<'EOF'
hypr={{ hypr_gradient hyprland_active_border blue }}
shell={{ shell_gradient hyprland_active_border blue }}
start={{ gradient_start hyprland_active_border blue }}
literal={{ gradient_start hyprland_active_border 0xff112233 }}
EOF
HOME="$empty_home" XDG_STATE_HOME="$empty_home/.local/state" OMARCHY_PATH="$ROOT" PATH="$ROOT/bin:$PATH" \
"$ROOT/bin/omarchy-theme-set-templates" 2>"$test_tmp/empty.err"
[[ ! -s $test_tmp/empty.err ]] ||
fail "empty theme colors render without errors" "$(cat "$test_tmp/empty.err")"
expected_empty=$(cat <<'EOF'
hypr="#336699"
shell=#336699
start=#336699
literal=#112233
EOF
)
[[ $(<"$empty_next/empty-fallback.txt") == "$expected_empty" ]] ||
fail "empty theme colors use their gradient fallbacks: $(diff <(printf '%s\n' "$expected_empty") "$empty_next/empty-fallback.txt")"
pass "empty theme colors fall back cleanly in gradient helpers"