{"action":"created","issue":{"url":"https://api.github.com/repos/Hammerspoon/hammerspoon/issues/529","labels_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/issues/529/labels{/name}","comments_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/issues/529/comments","events_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/issues/529/events","html_url":"https://github.com/Hammerspoon/hammerspoon/issues/529","id":103984517,"number":529,"title":"Check if application is running and perform action when it closes","user":{"login":"kdheepak89","id":1813121,"avatar_url":"https://avatars.githubusercontent.com/u/1813121?v=3","gravatar_id":"","url":"https://api.github.com/users/kdheepak89","html_url":"https://github.com/kdheepak89","followers_url":"https://api.github.com/users/kdheepak89/followers","following_url":"https://api.github.com/users/kdheepak89/following{/other_user}","gists_url":"https://api.github.com/users/kdheepak89/gists{/gist_id}","starred_url":"https://api.github.com/users/kdheepak89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kdheepak89/subscriptions","organizations_url":"https://api.github.com/users/kdheepak89/orgs","repos_url":"https://api.github.com/users/kdheepak89/repos","events_url":"https://api.github.com/users/kdheepak89/events{/privacy}","received_events_url":"https://api.github.com/users/kdheepak89/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-31T05:00:11Z","updated_at":"2015-08-31T06:05:40Z","closed_at":"2015-08-31T06:05:40Z","body":"Hi, I'm not sure if this is the best place to post this. But I'm curious to know if this is possible with hammerspoon. I would basically like to run a script when an application exits."},"comment":{"url":"https://api.github.com/repos/Hammerspoon/hammerspoon/issues/comments/136276698","html_url":"https://github.com/Hammerspoon/hammerspoon/issues/529#issuecomment-136276698","issue_url":"https://api.github.com/repos/Hammerspoon/hammerspoon/issues/529","id":136276698,"user":{"login":"cmsj","id":353427,"avatar_url":"https://avatars.githubusercontent.com/u/353427?v=3","gravatar_id":"","url":"https://api.github.com/users/cmsj","html_url":"https://github.com/cmsj","followers_url":"https://api.github.com/users/cmsj/followers","following_url":"https://api.github.com/users/cmsj/following{/other_user}","gists_url":"https://api.github.com/users/cmsj/gists{/gist_id}","starred_url":"https://api.github.com/users/cmsj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmsj/subscriptions","organizations_url":"https://api.github.com/users/cmsj/orgs","repos_url":"https://api.github.com/users/cmsj/repos","events_url":"https://api.github.com/users/cmsj/events{/privacy}","received_events_url":"https://api.github.com/users/cmsj/received_events","type":"User","site_admin":false},"created_at":"2015-08-31T06:05:40Z","updated_at":"2015-08-31T06:05:40Z","body":"You can discover if an application is running using `hs.appfinder.appFromName()` and use `hs.application.watcher` to register a callback function for application events, which include a `terminated` event. Note that the information available for termination events is very limited, so you may need to record the PID of the application while it's running, to compare against later in the callback.\r\n\r\nLet us know if you have any problems getting it running :)"}}