#!/bin/sh
set -e

RUNTIME="/usr/lib/focus-guard/runtime-python3"

case "$1" in
  configure)
    # Copy the real interpreter so we can grant CAP_NET_BIND_SERVICE without
    # modifying the system-wide /usr/bin/python3.
    PY="$(readlink -f /usr/bin/python3)"
    if [ -n "$PY" ] && [ -x "$PY" ]; then
      install -D -m 0755 "$PY" "$RUNTIME"
      if command -v setcap >/dev/null 2>&1; then
        setcap cap_net_bind_service=+ep "$RUNTIME" || true
      fi
    fi
    if command -v update-desktop-database >/dev/null 2>&1; then
      update-desktop-database -q /usr/share/applications || true
    fi
    if command -v gtk-update-icon-cache >/dev/null 2>&1; then
      gtk-update-icon-cache -f -t /usr/share/icons/hicolor >/dev/null 2>&1 || true
    fi
    ;;
esac

#DEBHELPER#

exit 0
