fix: correctly omit --icon from notify-send when not set

This commit is contained in:
Michael Aquilina 2024-05-13 10:48:41 +01:00
parent 452eee9454
commit 0e4ed6b3c5
No known key found for this signature in database
GPG key ID: 636066730B056BD1
2 changed files with 4 additions and 4 deletions

View file

@ -59,12 +59,12 @@ function _auto_notify_message() {
transient="" transient=""
icon=${AUTO_NOTIFY_ICON_FAILURE:-""} icon=${AUTO_NOTIFY_ICON_FAILURE:-""}
fi fi
local icon_arg=""
if [[ -n "$icon" ]]; then if [[ -n "$icon" ]]; then
icon_arg="--icon=$icon" notify-send "$title" "$body" --app-name=zsh $transient "--urgency=$urgency" "--expire-time=$AUTO_NOTIFY_EXPIRE_TIME" "--icon=$icon"
else
notify-send "$title" "$body" --app-name=zsh $transient "--urgency=$urgency" "--expire-time=$AUTO_NOTIFY_EXPIRE_TIME"
fi fi
notify-send "$title" "$body" --app-name=zsh $transient "--urgency=$urgency" "--expire-time=$AUTO_NOTIFY_EXPIRE_TIME" "$icon_arg"
elif [[ "$platform" == "Darwin" ]]; then elif [[ "$platform" == "Darwin" ]]; then
osascript \ osascript \
-e 'on run argv' \ -e 'on run argv' \

View file

@ -89,7 +89,7 @@
assert "$lines[1]" same_as 'Notification Title: "f bar -r" Completed' assert "$lines[1]" same_as 'Notification Title: "f bar -r" Completed'
assert "$lines[2]" same_as "Notification Body: Total time: 20 seconds" assert "$lines[2]" same_as "Notification Body: Total time: 20 seconds"
assert "$lines[3]" same_as "Exit code: 0" 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:1 --urgency=normal --expire-time=15000"
} }
@test 'auto-notify-send sends notification and icon on Linux on success' { @test 'auto-notify-send sends notification and icon on Linux on success' {