mirror of
https://github.com/basecamp/omarchy.git
synced 2026-02-17 15:25:37 +00:00
27 lines
986 B
Bash
Executable File
27 lines
986 B
Bash
Executable File
#!/bin/bash
|
|
|
|
TEMPLATES_DIR="$OMARCHY_PATH/themes/templates.d"
|
|
CURRENT_THEME_DIR="$HOME/.config/omarchy/current/theme"
|
|
COLORS_FILE="$CURRENT_THEME_DIR/colors.toml"
|
|
|
|
# Only generate dynamic templates for themes with a colors.toml definition
|
|
if [[ -f $COLORS_FILE ]]; then
|
|
# Parse TOML using yq (treating it as YAML since the flat key=value structure is compatible)
|
|
# We convert 'key = value' to 'key: value' to make it valid YAML, then use yq/jq to generate the replacement commands.
|
|
sed_script=$(mktemp)
|
|
sed 's/=/:/' "$COLORS_FILE" | yq -r 'to_entries[] | "s|{{ \(.key) }}|\(.value)|g"' > "$sed_script"
|
|
|
|
shopt -s nullglob
|
|
for tpl in "$TEMPLATES_DIR"/*.tpl; do
|
|
filename=$(basename "$tpl" .tpl)
|
|
output_path="$CURRENT_THEME_DIR/$filename"
|
|
|
|
# Don't overwrite configs already exists in the output directory (copied from theme specific folder)
|
|
if [[ ! -f $output_path ]]; then
|
|
sed -f "$sed_script" "$tpl" > "$output_path"
|
|
fi
|
|
done
|
|
|
|
rm "$sed_script"
|
|
fi
|