Return a default notification command based on the operating system.
(self)
| 1052 | self.bell_on_next_input = True |
| 1053 | |
| 1054 | def get_default_notification_command(self): |
| 1055 | """Return a default notification command based on the operating system.""" |
| 1056 | import platform |
| 1057 | |
| 1058 | system = platform.system() |
| 1059 | |
| 1060 | if system == "Darwin": # macOS |
| 1061 | # Check for terminal-notifier first |
| 1062 | if shutil.which("terminal-notifier"): |
| 1063 | return f"terminal-notifier -title 'Aider' -message '{NOTIFICATION_MESSAGE}'" |
| 1064 | # Fall back to osascript |
| 1065 | return ( |
| 1066 | f'osascript -e \'display notification "{NOTIFICATION_MESSAGE}" with title "Aider"\'' |
| 1067 | ) |
| 1068 | elif system == "Linux": |
| 1069 | # Check for common Linux notification tools |
| 1070 | for cmd in ["notify-send", "zenity"]: |
| 1071 | if shutil.which(cmd): |
| 1072 | if cmd == "notify-send": |
| 1073 | return f"notify-send 'Aider' '{NOTIFICATION_MESSAGE}'" |
| 1074 | elif cmd == "zenity": |
| 1075 | return f"zenity --notification --text='{NOTIFICATION_MESSAGE}'" |
| 1076 | return None # No known notification tool found |
| 1077 | elif system == "Windows": |
| 1078 | # PowerShell notification |
| 1079 | return ( |
| 1080 | "powershell -command" |
| 1081 | " \"[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms');" |
| 1082 | f" [System.Windows.Forms.MessageBox]::Show('{NOTIFICATION_MESSAGE}'," |
| 1083 | " 'Aider')\"" |
| 1084 | ) |
| 1085 | |
| 1086 | return None # Unknown system |
| 1087 | |
| 1088 | def ring_bell(self): |
| 1089 | """Ring the terminal bell if needed and clear the flag""" |