From cf1086830539882bdccbcd9eaaa4df876623a257 Mon Sep 17 00:00:00 2001 From: Lysec Date: Sun, 25 Jan 2026 11:51:36 +0100 Subject: [PATCH] template-apply: fix alacritty theming --- Scripts/bash/template-apply.sh | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/Scripts/bash/template-apply.sh b/Scripts/bash/template-apply.sh index e6f70e86e..ae438c566 100755 --- a/Scripts/bash/template-apply.sh +++ b/Scripts/bash/template-apply.sh @@ -72,28 +72,29 @@ EOF alacritty) CONFIG_FILE="$HOME/.config/alacritty/alacritty.toml" - # Check if the config file exists. - if [ -f "$CONFIG_FILE" ]; then - # Check if theme is already imported - if ! grep -q 'import = \[.*"themes/noctalia.toml".*\]' "$CONFIG_FILE"; then + # Check if the config file exists, create it if it doesn't. + if [ ! -f "$CONFIG_FILE" ]; then + # Create the config directory if it doesn't exist + mkdir -p "$(dirname "$CONFIG_FILE")" + # Create the config file with the noctalia theme import + cat >"$CONFIG_FILE" <<'EOF' +[general] +import = [ + "~/.config/alacritty/themes/noctalia.toml" +] +EOF + else + # Check if theme is already imported (checking for the exact path) + if ! grep -q '"~/.config/alacritty/themes/noctalia.toml"' "$CONFIG_FILE"; then # Check if [general] section exists if grep -q '^\[general\]' "$CONFIG_FILE"; then - # Check if import line exists under [general] - if sed -n '/^\[general\]/,/^\[/p' "$CONFIG_FILE" | grep -q '^import = \['; then - # Replace existing import line with noctalia theme - sed -i '/^\[general\]/,/^\[/{s|^import = \[.*\]|import = ["themes/noctalia.toml"]|}' "$CONFIG_FILE" - else - # Add import line after [general] section - sed -i '/^\[general\]/a import = ["themes/noctalia.toml"]' "$CONFIG_FILE" - fi + # Add import line after [general] section header + sed -i '/^\[general\]/a import = ["~/.config/alacritty/themes/noctalia.toml"]' "$CONFIG_FILE" else # Create [general] section with import at the beginning of the file - sed -i '1i [general]\nimport = ["themes/noctalia.toml"]\n' "$CONFIG_FILE" + sed -i '1i [general]\nimport = ["~/.config/alacritty/themes/noctalia.toml"]\n' "$CONFIG_FILE" fi fi - else - echo "Error: alacritty config file not found at $CONFIG_FILE" >&2 - exit 1 fi ;;