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:
#!/usr/bin/python # 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: time.sleep(1) 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
- Save above script into
- Assign execution attributes by:
chmod +x get_active_focus.pycommand.
- Run it as:
$ ./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).