-
-
Save baruch/e968bb9fc67f8a8e27a439f7a3f90640 to your computer and use it in GitHub Desktop.
kitty notification script to mark the window urgent, get notified and pointed to the window when Claude Code waits for input
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # Kitty notification scripts, save it as ~/.config/kitty/notifications.py | |
| """ | |
| Diagnostic notifications.py for ~/.config/kitty/notifications.py | |
| This script runs INSIDE the kitty process (not a subprocess). | |
| It marks the window as urgent so it shows up in the workspace and remains marked after the notification is gone. | |
| """ | |
| from kitty.notifications import NotificationCommand | |
| import os | |
| import subprocess | |
| def main(notification: NotificationCommand) -> bool: | |
| #if notification.application_name != 'Claude Code': | |
| # return False | |
| # This kitty process IS the one that received the notification, | |
| # so xdotool gives us exactly the right X window ID | |
| try: | |
| pid = os.getpid() | |
| result = subprocess.run(["xdotool", "search", "--pid", str(pid)], capture_output=True, text=True) | |
| xwid = result.stdout.strip().splitlines()[0] if result.stdout.strip() else None | |
| if xwid: | |
| subprocess.run(["xdotool", "set_window", "--urgency", "1", xwid]) | |
| except Exception as e: | |
| print(f"ERROR: {e}") # Goes to: journalctl --user -fxe | |
| return False # still send the notification normally |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment