Skip to content

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

@ghost

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions