#!/usr/bin/env bash
#winezgui-remove-broken-links
winezgui-remove-broken-links()
{
  dbug "I: $(basename ${0}): Launched ${FUNCNAME[0]}"
    
  SOURCE "script-check-variables-loaded-or-not"
  script-check-variables-loaded-or-not

  # If running from inside flatpak, it can't detect other links properly due to no access to other flatpak's dir ~/.var/app/<other_flatpak>
  if [ $(flatpak-spawn echo 0 2>/dev/null) ] ; then
       find ${APPLICATIONSDIR} -iname "*${FLATPAK_NAME}*" -xtype l -delete  
  else
       find ${APPLICATIONSDIR} -iname "*winezgui*" -xtype l -delete
  fi

  ${UPDATE_DESKTOP_DATABASE} ${APPLICATIONSDIR} 2>/dev/null
  ${UPDATE_ICON_CACHE} 2>/dev/null
}
