When introducing an uninstaller for some MAC OS applications, we came up with an idea. As SerpicoLugNut says:
Seriously - 98% of Mac apps don’t offer an uninstaller, and if most people want the app to be uninstalled, they just drag and drop the app into the trash
We decided that we can watch Trash, and if our application appears in the basket, we can ask the user if he wants to delete it.
Fortunately, the MAC OS provides built-in functions to implement this. You just need to put the following .plist in / Library / LaunchAgents:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.your.app</string> <key>WatchPaths</key> <array> <string>~/.Trash</string> </array> <key>ProgramArguments</key> <array> <string>osascript</string> <string>/path/to/your/app/Check Trash.applescript</string> </array> <key>KeepAlive</key> <false/>
In this example, a Check Trash.applescript run after the user trash changes. This script should check that your application is in the trash and ask the user if he wants to continue uninstalling. Of course, it could be an arbitrary script or even a binary executable, not just applescript. See the man page for launchd.plist for more information.
source share