#!/usr/bin/env bash
# Undo install.sh: remove the per-user desktop entry, MIME definitions,
# and icons this bundle installed. Leaves the extracted FunGen/ folder
# itself untouched (delete that by hand).
#
# Usage:  ./uninstall.sh
set -euo pipefail

DATA="${XDG_DATA_HOME:-$HOME/.local/share}"
APPS="$DATA/applications"
MIMEPKG="$DATA/mime/packages"
ICONS="$DATA/icons/hicolor"

echo "==> removing desktop entry + MIME definitions"
rm -f "$APPS/fungen.desktop"
rm -f "$MIMEPKG/fungen-mime.xml"

# Icons we installed (named fungen.png across the size buckets).
for sz in 16 32 48 64 128 256 512; do
    rm -f "$ICONS/${sz}x${sz}/apps/fungen.png"
done

command -v update-mime-database    >/dev/null && update-mime-database "$DATA/mime" || true
command -v update-desktop-database >/dev/null && update-desktop-database "$APPS"   || true
command -v gtk-update-icon-cache   >/dev/null && gtk-update-icon-cache -q -t -f "$ICONS" 2>/dev/null || true

echo "==> done. FunGen file associations removed for this user."
