#!/usr/bin/env bash

function overlay_file() {
    local SYSTEM_FILE="/usr/share/ubuntu-mate/settings-overlay/${1}"
    local USER_FILE="${HOME}/.${1}"
    local USER_DIR=$(dirname "${USER_FILE}")

    # If the file doesn't exist or is zero-bytes then overlay the
    # configuration.
    if [ ! -f "${USER_FILE}" ] || [ ! -s "${USER_FILE}" ]; then
        mkdir -p "${USER_DIR}"
        cp "${SYSTEM_FILE}" "${USER_FILE}"
    fi
}

if [ ! -d "${HOME}/.config/plank/dock1" ]; then
    overlay_file config/plank/dock1/launchers/clock.dockitem
    overlay_file config/plank/dock1/launchers/desktop.dockitem
    overlay_file config/plank/dock1/launchers/firefox.dockitem
    overlay_file config/plank/dock1/launchers/caja.dockitem
    overlay_file config/plank/dock1/launchers/matecc.dockitem
    overlay_file config/plank/dock1/launchers/ubuntu-mate-welcome.dockitem
fi
overlay_file config/folder-color/hide_donation
overlay_file config/smplayer/smplayer.ini
overlay_file config/tilda/config_0
overlay_file config/Trolltech.conf