# Apply dotfiles: copy the plain tree in 03-user/dotfiles/ into $HOME.
DOTS="$REPO_ROOT/03-user/dotfiles"
if [ -z "$(ls -A "$DOTS" 2>/dev/null)" ]; then
  echo "   03-user/dotfiles empty — nothing to deploy"
  return 0 2>/dev/null || exit 0
fi

cp -a "$DOTS/." "$HOME/"

# If exec bits were lost in transit (USB exFAT / optional custom ISO), restore them
# on the deployed scripts. They're all shebang scripts (no binaries) → detect by shebang.
grep -rlI '^#!' "$HOME/scripts" "$HOME/.config/waybar/scripts" 2>/dev/null \
  | xargs -r chmod +x
