mirror of
https://github.com/basecamp/omarchy.git
synced 2026-02-17 15:25:37 +00:00
Pull out the dynamic template rendering again, but simpler
This commit is contained in:
@@ -11,47 +11,20 @@ CURRENT_THEME_DIR="$HOME/.config/omarchy/current/theme"
|
|||||||
THEME_NAME=$(echo "$1" | sed -E 's/<[^>]+>//g' | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
|
THEME_NAME=$(echo "$1" | sed -E 's/<[^>]+>//g' | tr '[:upper:]' '[:lower:]' | tr ' ' '-')
|
||||||
THEME_PATH="$THEMES_DIR/$THEME_NAME"
|
THEME_PATH="$THEMES_DIR/$THEME_NAME"
|
||||||
|
|
||||||
# Check if the theme entered exists
|
|
||||||
if [[ ! -d "$THEME_PATH" ]]; then
|
if [[ ! -d "$THEME_PATH" ]]; then
|
||||||
echo "Theme '$THEME_NAME' does not exist in $THEMES_DIR"
|
echo "Theme '$THEME_NAME' does not exist in $THEMES_DIR"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Setup theme directory
|
# Setup clean theme directory
|
||||||
if [[ -L "$CURRENT_THEME_DIR" ]]; then
|
rm -rf "$CURRENT_THEME_DIR"
|
||||||
rm "$CURRENT_THEME_DIR"
|
|
||||||
elif [[ -d "$CURRENT_THEME_DIR" ]]; then
|
|
||||||
rm -rf "$CURRENT_THEME_DIR"
|
|
||||||
fi
|
|
||||||
mkdir -p "$CURRENT_THEME_DIR"
|
mkdir -p "$CURRENT_THEME_DIR"
|
||||||
|
|
||||||
# Copy static configs
|
# Copy static configs
|
||||||
cp -r "$THEME_PATH/"* "$CURRENT_THEME_DIR/" 2>/dev/null
|
cp -r "$THEME_PATH/"* "$CURRENT_THEME_DIR/" 2>/dev/null
|
||||||
|
|
||||||
# Generate dynamic configs
|
# Generate dynamic configs
|
||||||
TEMPLATES_DIR="$THEMES_DIR/templates.d"
|
omarchy-theme-set-templates
|
||||||
COLORS_FILE="$THEME_PATH/colors.toml"
|
|
||||||
|
|
||||||
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
|
# Change background with theme
|
||||||
omarchy-theme-bg-next
|
omarchy-theme-bg-next
|
||||||
@@ -66,7 +39,7 @@ hyprctl reload
|
|||||||
pkill -SIGUSR2 btop
|
pkill -SIGUSR2 btop
|
||||||
makoctl reload
|
makoctl reload
|
||||||
|
|
||||||
# Change gnome, browser, vscode, cursor themes
|
# Change app-specific themes
|
||||||
omarchy-theme-set-gnome
|
omarchy-theme-set-gnome
|
||||||
omarchy-theme-set-browser
|
omarchy-theme-set-browser
|
||||||
omarchy-theme-set-vscode
|
omarchy-theme-set-vscode
|
||||||
|
|||||||
26
bin/omarchy-theme-set-templates
Executable file
26
bin/omarchy-theme-set-templates
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
TEMPLATES_DIR="$OMARCHY_PATH/themes/templates.d"
|
||||||
|
COLORS_FILE="$HOME/.config/omarchy/current/theme/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"
|
||||||
|
|
||||||
|
# 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
|
||||||
Reference in New Issue
Block a user