fix(hooks): handle missing tkinter cleanly in flashbang.sh
tkinter was imported at module level, before the try/except that was meant to catch a missing display or toolkit. On a Python install without the (often separately packaged) tkinter module, the script crashed instead of falling back to notify-send. The import is now wrapped in its own try/except with the same fallback. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
b59d355e99
commit
077eaa55be
@@ -16,7 +16,6 @@ import re
|
|||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tkinter as tk
|
|
||||||
|
|
||||||
|
|
||||||
def notify_fallback() -> None:
|
def notify_fallback() -> None:
|
||||||
@@ -25,6 +24,13 @@ def notify_fallback() -> None:
|
|||||||
subprocess.run([notify_send, "AI assistant requires attention"], check=False)
|
subprocess.run([notify_send, "AI assistant requires attention"], check=False)
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
import tkinter as tk
|
||||||
|
except ImportError:
|
||||||
|
notify_fallback()
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
def monitor_bounds(primary_only: bool) -> tuple[int, int, int, int]:
|
def monitor_bounds(primary_only: bool) -> tuple[int, int, int, int]:
|
||||||
root = tk.Tk()
|
root = tk.Tk()
|
||||||
root.withdraw()
|
root.withdraw()
|
||||||
|
|||||||
Reference in New Issue
Block a user