mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 17:24:59 +00:00
feat: Add OS-specific default notification commands with custom message
This commit is contained in:
parent
56ba7ef411
commit
93b86a8800
2 changed files with 29 additions and 2 deletions
|
@ -826,7 +826,7 @@ def get_parser(default_config_files, git_root):
|
||||||
"--notifications-command",
|
"--notifications-command",
|
||||||
metavar="COMMAND",
|
metavar="COMMAND",
|
||||||
default=None,
|
default=None,
|
||||||
help="Specify a command to run for notifications instead of the terminal bell",
|
help="Specify a command to run for notifications instead of the terminal bell. If not specified, a default command for your OS may be used.",
|
||||||
)
|
)
|
||||||
group.add_argument(
|
group.add_argument(
|
||||||
"--detect-urls",
|
"--detect-urls",
|
||||||
|
|
29
aider/io.py
29
aider/io.py
|
@ -1,6 +1,7 @@
|
||||||
import base64
|
import base64
|
||||||
import functools
|
import functools
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
import signal
|
import signal
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
|
@ -248,7 +249,10 @@ class InputOutput:
|
||||||
self.multiline_mode = multiline_mode
|
self.multiline_mode = multiline_mode
|
||||||
self.bell_on_next_input = False
|
self.bell_on_next_input = False
|
||||||
self.notifications = notifications
|
self.notifications = notifications
|
||||||
self.notifications_command = notifications_command
|
if notifications and notifications_command is None:
|
||||||
|
self.notifications_command = self.get_default_notification_command()
|
||||||
|
else:
|
||||||
|
self.notifications_command = notifications_command
|
||||||
no_color = os.environ.get("NO_COLOR")
|
no_color = os.environ.get("NO_COLOR")
|
||||||
if no_color is not None and no_color != "":
|
if no_color is not None and no_color != "":
|
||||||
pretty = False
|
pretty = False
|
||||||
|
@ -955,6 +959,29 @@ class InputOutput:
|
||||||
"""Clear the bell flag (optional, as we'll clear it after ringing)"""
|
"""Clear the bell flag (optional, as we'll clear it after ringing)"""
|
||||||
self.bell_on_next_input = False
|
self.bell_on_next_input = False
|
||||||
|
|
||||||
|
def get_default_notification_command(self):
|
||||||
|
"""Return a default notification command based on the operating system."""
|
||||||
|
import platform
|
||||||
|
|
||||||
|
system = platform.system()
|
||||||
|
|
||||||
|
if system == "Darwin": # macOS
|
||||||
|
return "osascript -e 'display notification \"Aider is waiting for your input\" with title \"Aider\"'"
|
||||||
|
elif system == "Linux":
|
||||||
|
# Check for common Linux notification tools
|
||||||
|
for cmd in ["notify-send", "zenity"]:
|
||||||
|
if shutil.which(cmd):
|
||||||
|
if cmd == "notify-send":
|
||||||
|
return "notify-send 'Aider' 'Aider is waiting for your input'"
|
||||||
|
elif cmd == "zenity":
|
||||||
|
return "zenity --notification --text='Aider is waiting for your input'"
|
||||||
|
return None # No known notification tool found
|
||||||
|
elif system == "Windows":
|
||||||
|
# PowerShell notification
|
||||||
|
return "powershell -command \"[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms'); [System.Windows.Forms.MessageBox]::Show('Aider is waiting for your input', 'Aider')\""
|
||||||
|
|
||||||
|
return None # Unknown system
|
||||||
|
|
||||||
def ring_bell(self):
|
def ring_bell(self):
|
||||||
"""Ring the terminal bell if needed and clear the flag"""
|
"""Ring the terminal bell if needed and clear the flag"""
|
||||||
if self.bell_on_next_input and self.notifications:
|
if self.bell_on_next_input and self.notifications:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue