#!/usr/bin/env bash

syncicon() {
    local logo_path iconpath destpath
    . <(grep '^logo_path=.*' "${XDG_CONFIG_HOME:-"$HOME/.config"}/PINCE/PINCE.conf")
    iconpath="/usr/share/PINCE/media/logo/$logo_path"
    destpath="${XDG_DATA_HOME:-"$HOME/.local/share"}/icons/hicolor/256x256/apps/PINCE.png"
    mkdir -p "$(dirname "$destpath")"
    ln -sf "$iconpath" "$destpath"
    echo -e "\nDesktop icon updated: $destpath"
    echo "If the setting of icon changed, Re-login for setting to take effect."
}

pushd "/usr/share/PINCE" || exit 1
sh PINCE.sh "$@"
syncicon
popd || exit 1

read -p "Press enter to exit..."

