#!/bin/sh

die() {
  echo "Error: $1"
  exit
}

if [ $# -ne 1 ]; then
  echo "Usage: $0 DESTDIR"
  echo "This will install the themes to DESTDIR/"
  exit
fi

DESTDIR="$1"

D=$(dirname $0)
this_script=$(basename $0)
[ -f "${D}/${this_script}" ] || die "Can't find this script; expected to find it so it can be excluded from the install."

mkdir -p "${DESTDIR}" || die "Couldn't make directory ${DESTDIR}"

rsync -rlptv \
  --exclude="/${this_script}" \
  --exclude="make" \
  --exclude='*~' \
  --exclude='*.swp' \
  --exclude='*.bak' \
  --exclude='*.xcf' \
  --exclude='*.svg' \
  "${D}/" "${DESTDIR}"

