fix(theme): exit on missing theme; persist bg picks across rebuilds

Two related bugs in the theme switcher scripts:

(1) nomarchy-theme-set printed a warning when the theme directory didn't
exist but kept going — it wrote the bad name into state.json and ran
nomarchy-env-update on a broken state. Added an exit 1 after the
warning.

(2) nomarchy-theme-bg-set updated the live ~/.config/nomarchy/current/
background symlink + restarted swaybg but never wrote state.json. The
script is called by the walker background-selector menu
(elephant/nomarchy_background_selector.lua) and by the nomarchy-
wallpaper CLI wrapper, so every wallpaper picked via either path
silently reverted to the active theme's default on the next
home-manager switch — themes/engine/files.nix re-resolves
config.nomarchy.wallpaper at every rebuild. Now writes the chosen path
into state.json's wallpaper field, mirroring nomarchy-theme-bg-next.
Also added a file-exists check so a bogus path fails loudly instead of
leaving a dangling symlink + a failed swaybg process.
This commit is contained in:
Bernardo Magri
2026-05-21 20:35:52 +01:00
parent 4de8afbea9
commit 893fa91fbf
2 changed files with 24 additions and 3 deletions

View File

@@ -30,7 +30,8 @@ mkdir -p "$STATE_DIR"
[[ ! -f $STATE_FILE ]] && echo "{}" > "$STATE_FILE"
if [ ! -d "$THEMES_DIR/$THEME_NAME" ]; then
echo "Theme '$THEME_NAME' not found in $THEMES_DIR"
echo "Theme '$THEME_NAME' not found in $THEMES_DIR" >&2
exit 1
fi
TMP_JSON=$(mktemp)