mirror of
https://github.com/basecamp/omarchy.git
synced 2026-02-17 15:25:37 +00:00
Combine render into -set
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# omarchy-theme-render
|
||||
# Renders templates using values from a TOML configuration file.
|
||||
|
||||
COLORS_FILE="$1"
|
||||
TEMPLATES_DIR="$2"
|
||||
OUTPUT_DIR="$3"
|
||||
|
||||
if [[ -z $COLORS_FILE || -z $TEMPLATES_DIR || -z $OUTPUT_DIR ]]; then
|
||||
echo "Usage: omarchy-theme-render <colors_toml> <templates_dir> <output_dir>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Old themes don't have color files
|
||||
[[ ! -f "$COLORS_FILE" ]] && exit 1
|
||||
|
||||
# Configs are rendered into the output directory
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
|
||||
# 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"
|
||||
|
||||
# Process each template file
|
||||
# Enable nullglob to handle case where no templates exist
|
||||
shopt -s nullglob
|
||||
for tpl in "$TEMPLATES_DIR"/*.tpl; do
|
||||
filename=$(basename "$tpl" .tpl)
|
||||
output_path="$OUTPUT_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"
|
||||
@@ -17,7 +17,7 @@ if [[ ! -d "$THEME_PATH" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Prepare current theme directory (replacing symlink if it exists)
|
||||
# Setup theme directory
|
||||
if [[ -L "$CURRENT_THEME_DIR" ]]; then
|
||||
rm "$CURRENT_THEME_DIR"
|
||||
elif [[ -d "$CURRENT_THEME_DIR" ]]; then
|
||||
@@ -28,10 +28,30 @@ mkdir -p "$CURRENT_THEME_DIR"
|
||||
# Copy static configs
|
||||
cp -r "$THEME_PATH/"* "$CURRENT_THEME_DIR/" 2>/dev/null
|
||||
|
||||
# Generate configuration files from templates
|
||||
# Generate dynamic configs
|
||||
TEMPLATES_DIR="$THEMES_DIR/templates.d"
|
||||
COLORS_FILE="$THEME_PATH/colors.toml"
|
||||
omarchy-theme-render "$COLORS_FILE" "$TEMPLATES_DIR" "$CURRENT_THEME_DIR"
|
||||
|
||||
if [[ -f $COLORS_FILE && -d $TEMPLATES_DIR ]]; 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"
|
||||
|
||||
# Process each template file
|
||||
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
|
||||
|
||||
# Change background with theme
|
||||
omarchy-theme-bg-next
|
||||
|
||||
Reference in New Issue
Block a user