#!/usr/bin/env bash

# flocate -a x11 | egrep -v -e /opt/local -e MacPorts -e Xcode \
                   -e CrossOver.app -e Kindle\ Previewer.app -e Wineskin \
                   -e smartbuild -e Frameworks

set -x

launchctl unload /Library/LaunchAgents/org.macosforge.xquartz*.plist
launchctl unload /Library/LaunchDaemons/org.macosforge.xquartz*.plist

rm -rfv /Applications/Utilities/XQuartz.app \
        /Applications/Utilities/X11.app \
        /Library/*/org.macosforge.xquartz.* \
        /Users/david/Library/Caches/*X11* \
        /Users/david/Library/Saved\ Application\ State/org.macosforge.xquartz.X11* \
        /usr/X11 /usr/X11R6 /opt/X11 \
        /Users/david/Library/Preferences/org.macosforge.xquartz.X11.plist \
        $(find /private -name '*X11*') \
        $(find /private -name '*xquartz*')

pkgutil --forget org.macosforge.xquartz.pkg
