From 2bf74d385efd85189027170e0ede7908702f2e14 Mon Sep 17 00:00:00 2001 From: Nameless Monarch Date: Sun, 12 Apr 2026 18:35:54 -0500 Subject: [PATCH 1/2] fix(theming): readjusting the starship config file for a more reliable script --- Scripts/bash/template-apply.sh | 106 +++++++++++++++++++-------------- 1 file changed, 61 insertions(+), 45 deletions(-) diff --git a/Scripts/bash/template-apply.sh b/Scripts/bash/template-apply.sh index 45e33bc07..c2acf161c 100755 --- a/Scripts/bash/template-apply.sh +++ b/Scripts/bash/template-apply.sh @@ -535,57 +535,73 @@ zathura) ;; starship) - # Check if the nested starship config exists first - if [ -f "$HOME/.config/starship/starship.toml" ]; then - CONFIG_FILE="$HOME/.config/starship/starship.toml" - else - # Fallback to the default path - CONFIG_FILE="$HOME/.config/starship.toml" - fi + PALETTE_FILE="$HOME/.cache/noctalia/starship-palette.toml" - # Check if the generated palette file exists - if [ ! -f "$PALETTE_FILE" ]; then - echo "Error: Starship palette file not found at $PALETTE_FILE" >&2 - exit 1 - fi + # Respect STARSHIP_CONFIG env var, then fall back to standard lookup order + if [ -n "$STARSHIP_CONFIG" ]; then + CONFIG_FILE="$STARSHIP_CONFIG" + elif [ -f "$HOME/.config/starship.toml" ]; then + CONFIG_FILE="$HOME/.config/starship.toml" + elif [ -f "$HOME/.config/starship/starship.toml" ]; then + CONFIG_FILE="$HOME/.config/starship/starship.toml" + else + CONFIG_FILE="$HOME/.config/starship.toml" + fi - MARKER_BEGIN="# >>> NOCTALIA STARSHIP PALETTE >>>" - MARKER_END="# <<< NOCTALIA STARSHIP PALETTE <<<" + if [ ! -f "$PALETTE_FILE" ]; then + echo "Error: Starship palette file not found at $PALETTE_FILE" >&2 + return 1 + fi - # Create config file if it doesn't exist - if [ ! -f "$CONFIG_FILE" ]; then - mkdir -p "$(dirname "$CONFIG_FILE")" - echo 'palette = "noctalia"' > "$CONFIG_FILE" - echo "" >> "$CONFIG_FILE" - echo "$MARKER_BEGIN" >> "$CONFIG_FILE" - cat "$PALETTE_FILE" >> "$CONFIG_FILE" - echo "$MARKER_END" >> "$CONFIG_FILE" - exit 0 - fi + MARKER_BEGIN='# >>> NOCTALIA STARSHIP PALETTE >>>' + MARKER_END='# <<< NOCTALIA STARSHIP PALETTE <<<' - # 1. Set palette = "noctalia" at top level - if grep -qE '^palette\s*=' "$CONFIG_FILE"; then - sed -i -E 's/^palette\s*=.*/palette = "noctalia"/' "$CONFIG_FILE" - else - # Insert after schema line if present, otherwise at line 1 - if grep -qE '^\"\$schema\"' "$CONFIG_FILE"; then - sed -i '/^\"\$schema\"/a palette = "noctalia"' "$CONFIG_FILE" - else - sed -i '1i palette = "noctalia"' "$CONFIG_FILE" - fi - fi + # Create config file from scratch if it doesn't exist yet + if [ ! -f "$CONFIG_FILE" ]; then + mkdir -p "$(dirname "$CONFIG_FILE")" + { + printf 'palette = "noctalia"\n\n' + printf '%s\n' "$MARKER_BEGIN" + cat "$PALETTE_FILE" + printf '%s\n' "$MARKER_END" + } > "$CONFIG_FILE" + return 0 + fi - # 2. Remove existing noctalia palette block (between markers) - if grep -qF "$MARKER_BEGIN" "$CONFIG_FILE"; then - sed -i "/$(echo "$MARKER_BEGIN" | sed 's/[[\.*^$()+?{|]/\\&/g')/,/$(echo "$MARKER_END" | sed 's/[[\.*^$()+?{|]/\\&/g')/d" "$CONFIG_FILE" - fi + # Follow symlinks so we edit the real file (safe for stow / dotfile managers) + if [ -L "$CONFIG_FILE" ]; then + CONFIG_FILE="$(readlink -f "$CONFIG_FILE")" + fi - # 3. Append the new palette block - echo "" >> "$CONFIG_FILE" - echo "$MARKER_BEGIN" >> "$CONFIG_FILE" - cat "$PALETTE_FILE" >> "$CONFIG_FILE" - echo "$MARKER_END" >> "$CONFIG_FILE" - ;; + # Set or insert top-level palette = "noctalia" + if grep -qE '^[[:space:]]*palette[[:space:]]*=' "$CONFIG_FILE"; then + sed -i -E 's/^([[:space:]]*)palette([[:space:]]*)=.*/\1palette\2= "noctalia"/' "$CONFIG_FILE" + elif grep -qE '^[[:space:]]*"\$schema"' "$CONFIG_FILE"; then + sed -i '/^[[:space:]]*"\$schema"/a palette = "noctalia"' "$CONFIG_FILE" + else + sed -i '1i palette = "noctalia"' "$CONFIG_FILE" + fi + + # Remove existing palette block using awk for literal string matching + # (avoids sed misinterpreting >, #, or other chars in the markers as regex) + if grep -qF "$MARKER_BEGIN" "$CONFIG_FILE"; then + awk -v begin="$MARKER_BEGIN" -v end="$MARKER_END" ' + $0 == begin { skip = 1; next } + $0 == end { skip = 0; next } + !skip + ' "$CONFIG_FILE" > "${CONFIG_FILE}.noctalia.tmp" \ + && mv "${CONFIG_FILE}.noctalia.tmp" "$CONFIG_FILE" + fi + + # Append fresh palette block, ensuring a clean newline boundary + { + printf '\n%s\n' "$MARKER_BEGIN" + cat "$PALETTE_FILE" + # Guard: ensure palette file ends with newline before closing marker + tail -c1 "$PALETTE_FILE" | grep -q $'\n' || printf '\n' + printf '%s\n' "$MARKER_END" + } >> "$CONFIG_FILE" + ;; *) # Handle unknown application names. From a7c724181fca5d1aff2d47b18fa733504cfdbda2 Mon Sep 17 00:00:00 2001 From: Ly-sec <52084453+Ly-sec@users.noreply.github.com> Date: Thu, 16 Apr 2026 01:24:55 +0000 Subject: [PATCH 2/2] chore(flake): update flake.lock --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 5e8267dc6..1118b9464 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1775710090, - "narHash": "sha256-ar3rofg+awPB8QXDaFJhJ2jJhu+KqN/PRCXeyuXR76E=", + "lastModified": 1776169885, + "narHash": "sha256-l/iNYDZ4bGOAFQY2q8y5OAfBBtrDAaPuRQqWaFHVRXM=", "owner": "nixos", "repo": "nixpkgs", - "rev": "4c1018dae018162ec878d42fec712642d214fdfa", + "rev": "4bd9165a9165d7b5e33ae57f3eecbcb28fb231c9", "type": "github" }, "original": {