While in Chrome or Sublime Text and mail for sure, my window will lose focus on 5 minute intervals. How do I determine culprit so that I can eliminate it? I've tried a reboot and closing applications that I think might be responsible and can't figure out what's actually causing the problem.


You can use the following Python script which can tell you which app is currently on focus:

# Prints current window focus.
# See: https://apple.stackexchange.com/q/169277
from AppKit import NSWorkspace
import time
workspace = NSWorkspace.sharedWorkspace()
active_app = workspace.activeApplication()['NSApplicationName']
print('Active focus: ' + active_app)
while True:
    prev_app = active_app
    active_app = workspace.activeApplication()['NSApplicationName']
    if prev_app != active_app:
        print('Focus changed to: ' + active_app)

It will print active application which has the focus and any change every second.

Related script: Identify which app or process is stealing focus on OSX at Gist


  1. Save above script into get_active_focus.py file.
  2. Assign execution attributes by: chmod +x get_active_focus.py command.
  3. Run it as: ./get_active_focus.py.


$ ./get_active_focus.py
Active focus: Terminal
Focus changed to: Google Chrome

Once you found the affected application, consider uninstalling or killing it (if possible).

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged .