Skip to content
Open
Show file tree
Hide file tree
Changes from 8 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
80 changes: 80 additions & 0 deletions bin/omarchy-theme-color
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ parse_colors_file() {
key="${key//[\"\' ]/}" # strip quotes and spaces from key
[[ $key && $key != \#* ]] || continue # skip empty lines and comments

if [[ $key == "terminal_opacity" || $key == "terminal_blur" || $key == "terminal_blur_radius" ]]; then
value="${value%%#*}"
fi

if [[ $value == *[\"\']* ]]; then
value="${value#*[\"\']}"
value="${value%%[\"\']*}" # extract value between quotes (ignores inline comments)
Expand Down Expand Up @@ -173,6 +177,81 @@ parse_colors_file() {
return 0
}

resolve_terminal_settings() {
local declared_opacity="${THEME_COLORS[terminal_opacity]+set}"
local declared_blur="${THEME_COLORS[terminal_blur]+set}"
local blur="${THEME_COLORS[terminal_blur]-false}"
local opacity="${THEME_COLORS[terminal_opacity]-1.0}"
local radius="${THEME_COLORS[terminal_blur_radius]-20}"
local foot_blur ghostty_blur terminal

# These settings are scalar, so anything after the value is a TOML comment.
opacity="${opacity%%#*}"
opacity="${opacity%% *}"
blur="${blur%%#*}"
blur="${blur%% *}"
radius="${radius%%#*}"
radius="${radius%% *}"
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved

if [[ ! $opacity =~ ^(0([.][0-9]+)?|1([.]0+)?)$ ]]; then
printf 'omarchy-theme-color: invalid terminal_opacity %q; ignoring override\n' "$opacity" >&2
opacity="1.0"
declared_opacity=""
fi

if [[ $blur != "true" && $blur != "false" ]]; then
printf 'omarchy-theme-color: invalid terminal_blur %q; ignoring override\n' "$blur" >&2
blur="false"
declared_blur=""
fi

if [[ ! $radius =~ ^[0-9]{1,2}$ ]] || (( 10#$radius > 64 )); then
printf 'omarchy-theme-color: invalid terminal_blur_radius %q; using 20\n' "$radius" >&2
radius=20
else
radius=$((10#$radius))
fi

THEME_COLORS[terminal_opacity]="$opacity"
THEME_COLORS[terminal_blur]="$blur"

if [[ $blur == "true" ]]; then
THEME_COLORS[terminal_blur_radius]="$radius"
foot_blur="yes"
ghostty_blur="$radius"
else
THEME_COLORS[terminal_blur_radius]="0"
foot_blur="no"
ghostty_blur="false"
fi

# An absent or invalid declaration must not suppress Glassy or replace the
# user's settings. Keep scalar defaults for custom templates, but render
# complete config lines only for valid declarations in the stock templates.
for terminal in alacritty foot ghostty kitty; do
THEME_COLORS[terminal_opacity_$terminal]="# opacity is not set by this theme"
THEME_COLORS[terminal_blur_$terminal]="# blur is not set by this theme"
done

if [[ $declared_opacity ]]; then
THEME_COLORS[terminal_opacity_alacritty]="opacity = $opacity"
THEME_COLORS[terminal_opacity_foot]="alpha=$opacity"
THEME_COLORS[terminal_opacity_ghostty]="background-opacity = $opacity"
THEME_COLORS[terminal_opacity_kitty]="background_opacity $opacity"
fi

if [[ $declared_blur ]]; then
THEME_COLORS[terminal_blur_alacritty]="blur = $blur"
THEME_COLORS[terminal_blur_foot]="blur=$foot_blur"
THEME_COLORS[terminal_blur_ghostty]="background-blur = $ghostty_blur"
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
THEME_COLORS[terminal_blur_kitty]="background_blur ${THEME_COLORS[terminal_blur_radius]}"
else
# Foot reads blur only at launch. Preserve quattro's launch-ready default
# even while opaque, so a running terminal can later become Glassy.
THEME_COLORS[terminal_blur_foot]="blur=yes"
fi
}

resolve_theme_colors() {
local key

Expand Down Expand Up @@ -277,6 +356,7 @@ resolve_theme_colors() {
done

resolve_theme_mode
resolve_terminal_settings
THEME_COLORS[theme_type]="${THEME_COLORS[mode]}"
}

Expand Down
13 changes: 11 additions & 2 deletions bin/omarchy-theme-set
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,18 @@ mkdir -p "$NEXT_THEME_PATH"
# Copy official theme first, then overlay the user's theme on top
cp -r "$OMARCHY_THEMES_PATH/$THEME_NAME/"* "$NEXT_THEME_PATH/" 2>/dev/null

HYPRLAND_LUA_FROM_STOCK=0
if [[ -f $NEXT_THEME_PATH/hyprland.lua ]]; then
HYPRLAND_LUA_FROM_STOCK=1
fi

if theme_came_from_a_repo "$USER_THEMES_PATH/$THEME_NAME"; then
stage_installed_theme "$USER_THEMES_PATH/$THEME_NAME"
report_ignored_theme_files
else
if [[ -e $USER_THEMES_PATH/$THEME_NAME/hyprland.lua || -L $USER_THEMES_PATH/$THEME_NAME/hyprland.lua ]]; then
HYPRLAND_LUA_FROM_STOCK=0
fi
cp -r "$USER_THEMES_PATH/$THEME_NAME/"* "$NEXT_THEME_PATH/" 2>/dev/null
fi

Expand Down Expand Up @@ -454,8 +462,9 @@ if [[ $THEME_HEADLESS != "1" && $OMARCHY_THEME_SKIP_BACKGROUND != "1" ]]; then
fi
fi

# Generate dynamic configs
omarchy-theme-set-templates
# Generate dynamic configs. A declarative user overlay may extend bundled Lua,
# while a trusted user-supplied hyprland.lua remains authoritative.
OMARCHY_THEME_HYPRLAND_LUA_FROM_STOCK="$HYPRLAND_LUA_FROM_STOCK" omarchy-theme-set-templates

# Replacing the theme's still can cancel an active OWE intro even before the
# background link changes. Present its cover before replacing either path.
Expand Down
Loading