diff --git a/aider/args.py b/aider/args.py index bdfe74e28..871cbd9c3 100644 --- a/aider/args.py +++ b/aider/args.py @@ -819,6 +819,12 @@ def get_parser(default_config_files, git_root): default=False, help="Enable/disable terminal bell notifications when LLM responses are ready (default: False)", ) + group.add_argument( + "--notifications-command", + metavar="COMMAND", + default=None, + help="Specify a command to run for notifications instead of the terminal bell", + ) group.add_argument( "--detect-urls", action=argparse.BooleanOptionalAction, diff --git a/aider/io.py b/aider/io.py index 7d95a422e..6863b41e2 100644 --- a/aider/io.py +++ b/aider/io.py @@ -208,6 +208,7 @@ class InputOutput: num_user_asks = 0 clipboard_watcher = None bell_on_next_input = False + notifications_command = None def __init__( self, @@ -237,6 +238,7 @@ class InputOutput: multiline_mode=False, root=".", notifications=False, + notifications_command=None, ): self.placeholder = None self.interrupted = False @@ -245,6 +247,7 @@ class InputOutput: self.multiline_mode = multiline_mode self.bell_on_next_input = False self.notifications = notifications + self.notifications_command = notifications_command no_color = os.environ.get("NO_COLOR") if no_color is not None and no_color != "": pretty = False @@ -954,7 +957,14 @@ class InputOutput: def ring_bell(self): """Ring the terminal bell if needed and clear the flag""" if self.bell_on_next_input and self.notifications: - print("\a", end="", flush=True) # Ring the bell + if self.notifications_command: + try: + import subprocess + subprocess.run(self.notifications_command, shell=True) + except Exception as e: + self.tool_warning(f"Failed to run notifications command: {e}") + else: + print("\a", end="", flush=True) # Ring the bell self.bell_on_next_input = False # Clear the flag def toggle_multiline_mode(self): diff --git a/aider/main.py b/aider/main.py index b20e76896..d7661df9a 100644 --- a/aider/main.py +++ b/aider/main.py @@ -560,6 +560,7 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F fancy_input=args.fancy_input, multiline_mode=args.multiline, notifications=args.notifications, + notifications_command=args.notifications_command, ) io = get_io(args.pretty)