I writing an app for Mac, one of it's components is a launchctl agent that runs in background.
As mac apps are removed by dragging to trash (I can understand this logic but takes getting used to after years of windows dev'ing), I'm wondering is there anything I can do to cleanup after myself when the user removes the app?
specifically the running background process and its .plist file.
Edit: After some more thinking about the issue, I have an idea to put a listener on the background process file, get notified if it's deleted, then remove itself from launchctl, delete plist and kill itself. can this work?