2026-03-10 02:54:15 -04:00
|
|
|
"""Manual test: shows a pulsing border around Cursor windows for 10 seconds.
|
|
|
|
|
|
|
|
|
|
With no args, flashes all windows (for visual testing).
|
|
|
|
|
With --per-window, only flashes windows with active signals (production behavior).
|
|
|
|
|
"""
|
|
|
|
|
import argparse
|
2026-03-10 02:39:30 -04:00
|
|
|
import sys
|
|
|
|
|
import time
|
|
|
|
|
|
2026-03-10 02:54:15 -04:00
|
|
|
from ApplicationServices import (
|
|
|
|
|
AXUIElementCreateApplication,
|
|
|
|
|
AXUIElementCopyAttributeValue,
|
|
|
|
|
)
|
2026-03-10 02:39:30 -04:00
|
|
|
from Cocoa import NSApplication, NSRunLoop, NSDate
|
|
|
|
|
|
|
|
|
|
from cursor_flasher.config import Config
|
2026-03-10 02:44:04 -04:00
|
|
|
from cursor_flasher.overlay import OverlayManager
|
2026-03-10 02:39:30 -04:00
|
|
|
from cursor_flasher.detector import CursorDetector
|
|
|
|
|
|
|
|
|
|
app = NSApplication.sharedApplication()
|
|
|
|
|
|
2026-03-10 02:54:15 -04:00
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
|
parser.add_argument("--per-window", action="store_true",
|
|
|
|
|
help="Only flash windows that need attention")
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
2026-03-10 02:39:30 -04:00
|
|
|
config = Config()
|
2026-03-10 02:44:04 -04:00
|
|
|
overlay = OverlayManager(config)
|
2026-03-10 02:39:30 -04:00
|
|
|
detector = CursorDetector()
|
|
|
|
|
|
|
|
|
|
pid = detector._find_cursor_pid()
|
|
|
|
|
if pid is None:
|
|
|
|
|
print("Cursor not running")
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
2026-03-10 02:54:15 -04:00
|
|
|
if args.per_window:
|
|
|
|
|
result = detector.poll()
|
|
|
|
|
if result is None or not result.active_windows:
|
|
|
|
|
print("No windows currently need attention")
|
|
|
|
|
sys.exit(0)
|
|
|
|
|
ax_windows = result.active_windows
|
|
|
|
|
print(f"Flashing {len(ax_windows)} window(s) that need attention...")
|
|
|
|
|
else:
|
|
|
|
|
app_element = AXUIElementCreateApplication(pid)
|
|
|
|
|
_, children = AXUIElementCopyAttributeValue(app_element, "AXChildren", None)
|
|
|
|
|
ax_windows = []
|
|
|
|
|
for child in children:
|
|
|
|
|
_, role = AXUIElementCopyAttributeValue(child, "AXRole", None)
|
|
|
|
|
if str(role) == "AXWindow":
|
|
|
|
|
ax_windows.append(child)
|
|
|
|
|
print(f"Flashing all {len(ax_windows)} Cursor window(s)...")
|
|
|
|
|
|
|
|
|
|
overlay.show(ax_windows)
|
2026-03-10 02:39:30 -04:00
|
|
|
|
|
|
|
|
end_time = time.time() + 10
|
|
|
|
|
while time.time() < end_time:
|
|
|
|
|
NSRunLoop.currentRunLoop().runUntilDate_(
|
|
|
|
|
NSDate.dateWithTimeIntervalSinceNow_(0.1)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
overlay.hide()
|
|
|
|
|
print("Done.")
|