diff --git a/auto-notify.plugin.zsh b/auto-notify.plugin.zsh index 71b1f2c..25e446c 100644 --- a/auto-notify.plugin.zsh +++ b/auto-notify.plugin.zsh @@ -62,19 +62,17 @@ function _auto_notify_message() { fi elif [[ "$platform" == "Darwin" ]]; then - if [[ -z "$AUTO_NOTIFY_SOUND" ]]; then - osascript \ - -e 'on run argv' \ - -e 'display notification (item 1 of argv) with title (item 2 of argv)' \ - -e 'end run' \ - "$body" "$title" - else - osascript \ - -e 'on run argv' \ - -e 'display notification (item 1 of argv) with title (item 2 of argv) sound name (item 3 of argv)' \ - -e 'end run' \ - "$body" "$title" "$AUTO_NOTIFY_SOUND" + notification_command="display notification (item 1 of argv) with title (item 2 of argv)" + notification_body=($body $title) + if [[ ! -z "$AUTO_NOTIFY_SOUND" ]]; then + notification_command+=" sound name (item 3 of argv)" + notification_body+=("$AUTO_NOTIFY_SOUND") fi + osascript \ + -e 'on run argv' \ + -e ${notification_command[@]} \ + -e 'end run' \ + ${notification_body[@]} else printf "Unknown platform for sending notifications: $platform\n" printf "Please post an issue on gitub.com/MichaelAquilina/zsh-auto-notify/issues/\n"