#!/bin/sh
set -e

case "$1" in
    remove|purge)
        # Recompile GSettings schemas
        if command -v glib-compile-schemas >/dev/null 2>&1; then
            glib-compile-schemas /usr/share/glib-2.0/schemas/ || true
        fi

        # Remove autostart from existing users
        for HOME_DIR in /home/*; do
            [ -d "$HOME_DIR" ] || continue
            USER_NAME=$(basename "$HOME_DIR")
            USER_UID=$(id -u "$USER_NAME" 2>/dev/null) || continue
            [ "$USER_UID" -ge 1000 ] || continue
            rm -f "$HOME_DIR/.config/autostart/appindicator-extension-update.desktop"
        done
        ;;
esac

#DEBHELPER#
exit 0
