blob: ffa142a099e1cbc345816f3ea81312ea5fa386c0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#!/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."
|