Add option to configure persistence in notification history

Option AUTO_NOTIFY_ENABLE_TRANSIENT has been added
to enable and disable persistence in notification
history.
This commit is contained in:
Tommy Andersson 2025-02-12 22:38:53 +01:00
parent cbea4aeb58
commit 0317936051
3 changed files with 19 additions and 3 deletions

View File

@ -142,6 +142,19 @@ NOTE: This configuration option currently only works for Linux.
# Disable notification forwarding to SSH client
export AUTO_NOTIFY_ENABLE_SSH=0
**Notification Persistence in Notification History**
You can configure whether notifications will persist in notification history by setting the environment
variable ``AUTO_NOTIFY_ENABLE_TRANSIENT`` to enable ("1") or disable ("0"). The default value is set to 1.
NOTE: This configuration option currently only works for Linux.
::
# Enable persistent notifications
export AUTO_NOTIFY_ENABLE_TRANSIENT=0
# Disable persistent notifications
export AUTO_NOTIFY_ENABLE_TRANSIENT=1
**Ignored Commands**

View File

@ -9,6 +9,9 @@ export AUTO_NOTIFY_VERSION="0.10.2"
# Enable or disable notifications for SSH sessions (0 = disabled, 1 = enabled)
[[ -z "$AUTO_NOTIFY_ENABLE_SSH" ]] &&
export AUTO_NOTIFY_ENABLE_SSH=0
# Enable transient notifications to prevent them from being saved in the notification history
[[ -z "$AUTO_NOTIFY_ENABLE_TRANSIENT" ]] &&
export AUTO_NOTIFY_ENABLE_TRANSIENT=1
# List of commands/programs to ignore sending notifications for
[[ -z "$AUTO_NOTIFY_IGNORE" ]] &&
@ -55,7 +58,7 @@ function _auto_notify_message() {
if [[ "$platform" == "Linux" ]]; then
local urgency="normal"
local transient="--hint=int:transient:1"
local transient="--hint=int:transient:$AUTO_NOTIFY_ENABLE_TRANSIENT"
local icon=${AUTO_NOTIFY_ICON_SUCCESS:-""}
# Exit code 130 is returned when a process is terminated with SIGINT.
# Since the user is already interacting with the program, there is no

View File

@ -89,7 +89,7 @@
assert "$lines[1]" same_as 'Notification Title: "f bar -r" Completed'
assert "$lines[2]" same_as "Notification Body: Total time: 20 seconds"
assert "$lines[3]" same_as "Exit code: 0"
assert "$lines[4]" same_as "--app-name=zsh --hint=int:transient:1 --urgency=normal --expire-time=15000"
assert "$lines[4]" same_as "--app-name=zsh --hint=int:transient:0 --urgency=normal --expire-time=15000"
}
@test 'auto-notify-send sends notification and icon on Linux on success' {
@ -104,7 +104,7 @@
assert "$lines[1]" same_as 'Notification Title: "f bar -r" Completed'
assert "$lines[2]" same_as "Notification Body: Total time: 20 seconds"
assert "$lines[3]" same_as "Exit code: 0"
assert "$lines[4]" same_as "--app-name=zsh --hint=int:transient:1 --urgency=normal --expire-time=15000 --icon=/path/to/success/icon.png"
assert "$lines[4]" same_as "--app-name=zsh --hint=int:transient:0 --urgency=normal --expire-time=15000 --icon=/path/to/success/icon.png"
}
@test 'auto-notify-send sends notification on macOS' {