From febd18ce846c0605126a6ebc3efb0682db2731e8 Mon Sep 17 00:00:00 2001 From: Dominik <15915+dommmel@users.noreply.github.com> Date: Fri, 9 Jan 2026 15:39:07 +0100 Subject: [PATCH] Replace yq with pure bash for TOML parsing (#4171) * Replace yq with pure bash for TOML parsing The yq-based parsing only worked with jq/yq v3 and broke with go-yq v4. This change removes the yq and uses bash for parsing. Some additional improvments: - Handles single and double quoted values - Strips inline comments (e.g. "#hex" #comment) * Remove the no-longer-needed yq packages --------- Co-authored-by: David Heinemeier Hansson --- bin/omarchy-theme-set-templates | 21 ++++++++++----------- install/omarchy-base.packages | 1 - migrations/1767306902.sh | 2 -- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/bin/omarchy-theme-set-templates b/bin/omarchy-theme-set-templates index e49bdb50..fde3ad18 100755 --- a/bin/omarchy-theme-set-templates +++ b/bin/omarchy-theme-set-templates @@ -13,22 +13,21 @@ hex_to_rgb() { # 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) - # Generate standard and _strip substitutions - sed 's/=/:/' "$COLORS_FILE" | yq -r 'to_entries[] | "s|{{ \(.key) }}|\(.value)|g", "s|{{ \(.key)_strip }}|\(.value | sub("^#";""))|g"' > "$sed_script" - - # Generate _rgb substitutions for hex colors while IFS='=' read -r key value; do - key=$(echo "$key" | xargs) - value=$(echo "$value" | xargs | tr -d '"') + key="${key//[\"\' ]/}" # strip quotes and spaces from key + [[ $key && $key != \#* ]] || continue # skip empty lines and comments + value="${value#*[\"\']}" + value="${value%%[\"\']*}" # extract value between quotes (ignores inline comments) + + printf 's|{{ %s }}|%s|g\n' "$key" "$value" # {{ key }} -> value + printf 's|{{ %s_strip }}|%s|g\n' "$key" "${value#\#}" # {{ key_strip }} -> value without leading # if [[ $value =~ ^# ]]; then rgb=$(hex_to_rgb "$value") - echo "s|{{ ${key}_rgb }}|${rgb}|g" >> "$sed_script" + echo "s|{{ ${key}_rgb }}|${rgb}|g" fi - done < "$COLORS_FILE" + done <"$COLORS_FILE" >"$sed_script" shopt -s nullglob @@ -39,7 +38,7 @@ if [[ -f $COLORS_FILE ]]; then # 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" + sed -f "$sed_script" "$tpl" >"$output_path" fi done diff --git a/install/omarchy-base.packages b/install/omarchy-base.packages index 7373e0f1..d91ed9ad 100644 --- a/install/omarchy-base.packages +++ b/install/omarchy-base.packages @@ -144,5 +144,4 @@ xmlstarlet xournalpp yaru-icon-theme yay -yq zoxide diff --git a/migrations/1767306902.sh b/migrations/1767306902.sh index 9bd36a60..b8166e49 100644 --- a/migrations/1767306902.sh +++ b/migrations/1767306902.sh @@ -1,7 +1,5 @@ echo "Migrate to new theme setup" -omarchy-pkg-add yq - # Move user-added backgrounds from Omarchy theme folders to user config OMARCHY_DIR="$HOME/.local/share/omarchy" USER_BACKGROUNDS_DIR="$HOME/.config/omarchy/backgrounds"