#!/usr/bin/env bash # install-config.sh -- dev-box helper: sync config/ into the live config dir. # # On the development machine the live config dir IS the thing being iterated on, # so this is the inverse of the shipped installer: it overwrites the live files # from the repo, because the repo is now the source of truth. # # Backs up anything it is about to change, so a stray live-edit is never lost. # # ./install-config.sh [--dry-run] set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" DEST="${SL0PPIJ_CONFIG_DIR:-$HOME/.config/sl0ppij}" dry_run=0 [ "${1:-}" = "--dry-run" ] || [ "${1:-}" = "-n" ] && dry_run=1 sync_one() { local src="$1" dst="$2" if cmp -s "$src" "$dst"; then echo " same ${dst/#$HOME/\~}" return fi if [ "$dry_run" = 1 ]; then echo " would ${dst/#$HOME/\~}" return fi mkdir -p "$(dirname "$dst")" [ -e "$dst" ] && cp -a "$dst" "$dst.bak.$(date +%Y%m%d%H%M%S)" install -m644 "$src" "$dst" echo " updated ${dst/#$HOME/\~}" } echo "syncing config/ -> ${DEST/#$HOME/\~}" sync_one "$ROOT/config/config.kdl" "$DEST/config.kdl" for f in "$ROOT/config/layouts/"*.kdl; do sync_one "$f" "$DEST/layouts/$(basename "$f")"; done for f in "$ROOT/config/themes/"*.kdl; do sync_one "$f" "$DEST/themes/$(basename "$f")"; done echo echo "note: config changes hot-reload; renderer changes need a new session."