Merge pull request #72 from devnoname120/macos-dont-notify-ctrl-c

macOS: option to cancel notifications on SIGINT
This commit is contained in:
Michael Aquilina 2025-06-03 15:20:15 +01:00 committed by GitHub
commit da355e506c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -159,7 +159,6 @@ NOTE: This configuration option currently only works for Linux.
You can configure whether notifications will be cancelled when procees is terminated with SIGINT by setting the environment
variable ``AUTO_NOTIFY_CANCEL_ON_SIGINT`` to enable ("1") or disable ("0"). The default value is set to 0.
NOTE: This configuration option currently only works for Linux.
::

View File

@ -54,6 +54,12 @@ function _auto_notify_message() {
local DEFAULT_TITLE="\"%command\" Completed"
local DEFAULT_BODY="$(echo -e "Total time: %elapsed seconds\nExit code: %exit_code")"
# Exit code 130 indicates termination by SIGINT (Ctrl+C).
# If AUTO_NOTIFY_CANCEL_ON_SIGINT is enabled, suppress the notification.
if [[ "$exit_code" -eq 130 ]] && [[ "${AUTO_NOTIFY_CANCEL_ON_SIGINT}" -eq 1 ]]; then
return
fi
local title="${AUTO_NOTIFY_TITLE:-$DEFAULT_TITLE}"
local text="${AUTO_NOTIFY_BODY:-$DEFAULT_BODY}"
@ -68,11 +74,6 @@ function _auto_notify_message() {
# Handle specific exit codes
if [[ "$exit_code" -eq 130 ]]; then
# Exit code 130 indicates termination by SIGINT (Ctrl+C).
# If AUTO_NOTIFY_CANCEL_ON_SIGINT is enabled, suppress the notification.
if [[ "${AUTO_NOTIFY_CANCEL_ON_SIGINT}" -eq 1 ]]; then
return
fi
urgency="critical"
transient="--hint=int:transient:1"
icon="${AUTO_NOTIFY_ICON_FAILURE:-""}"