Skip to content

Instantly share code, notes, and snippets.

@eahrold
Created January 14, 2014 18:00
Show Gist options
  • Save eahrold/8422737 to your computer and use it in GitHub Desktop.
Save eahrold/8422737 to your computer and use it in GitHub Desktop.
close a running application with python and NSWorkspace
#!/usr/bin/python
from AppKit import NSWorkspace
def closeRunningApplication(bundle_id):
ws = NSWorkspace.sharedWorkspace()
runningApps = ws.runningApplications()
for i in runningApps:
if i.bundleIdentifier() == bundle_id:
i.terminate()
def main():
closeRunningApplication('app.bundle.id')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment