From cd376a37c0f16746cc319eb2e62bd14dba785a0e Mon Sep 17 00:00:00 2001 From: Zhiyuan Ma <631253076@qq.com> Date: Wed, 29 Apr 2026 01:27:37 -0700 Subject: [PATCH] Fix macOS collector startup and document Tk dependency for Apple Silicon --- README.md | 8 ++++++++ collector.py | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/README.md b/README.md index 9c86bfb..3b9d004 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,14 @@ pip install -r requirements.txt ./run_mac.sh ``` +Use a Python installation with Tk support. Some Homebrew Python builds on Apple +silicon do not bundle `tkinter` by default. If `import tkinter` fails, install +the matching Homebrew Tk package for your Python version. For example: + +```bash +brew install python-tk@3.14 +``` + Grant Screen Recording and Accessibility permissions to the terminal app or Python executable in System Settings. Restart the launcher after changing those permissions. diff --git a/collector.py b/collector.py index 5a66258..09f9b50 100644 --- a/collector.py +++ b/collector.py @@ -231,11 +231,15 @@ def __init__(self): self._label = None self._thread = None self._running = False + self._enabled = True self._pending_state = 'IDLE' self._pending_text = None self._dialog = None def start(self): + if OS_NAME == 'macos': + self._enabled = False + return self._running = True self._thread = threading.Thread(target=self._run_tk, daemon=True) self._thread.start() @@ -285,6 +289,8 @@ def _poll(self): self._root.after(80, self._poll) def update_state(self, state: str, extra: str = ''): + if not self._enabled: + return label = self.LABELS.get(state, state) if extra: label = f"{label} | {extra}" @@ -295,6 +301,11 @@ def stop(self): self._running = False def ask_description(self) -> Optional[str]: + if not self._enabled: + try: + return input("Task description: ").strip() + except EOFError: + return None self._dialog_result = None self._dialog_done = threading.Event() @@ -511,6 +522,8 @@ def callback(hmonitor, _hdc, _rect, _data): def choose_capture_screen_gui(monitors: List[ScreenRegion]) -> Optional[ScreenRegion]: + if OS_NAME == 'macos': + return None try: import tkinter as tk except Exception: