Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement: Replace the polling loop with use of the NSWorkspace's notificationCenter #15

Open
ghost opened this issue Mar 5, 2018 · 0 comments

Comments

@ghost
Copy link

ghost commented Mar 5, 2018

Presently, the script uses a polling loop to check the NSWorkspace's activeApplication (note: activeApplication is deprecated). It would be more efficient to register an observer for notification name NSWorkspaceDidActivateApplicationNotification, which notification is sent just as soon as an application is activated/focused.

I experimented with this approach in a currently private fork of this repository. Handling Ctrl+C / SIGINT was somewhat tricky, but I posted about how to do this on Stack Overflow:
https://stackoverflow.com/questions/49092405/how-to-register-a-sigint-handler-that-will-run-as-soon-as-ctrlc-is-pressed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants