refactor: Tidy if statement into concatenation

This commit is contained in:
Roeniss Moon 2024-03-23 23:22:47 +09:00
parent fc0e16d0f2
commit 77af2a8315
No known key found for this signature in database
GPG key ID: 2806329CE95C054D

View file

@ -62,19 +62,17 @@ function _auto_notify_message() {
fi fi
elif [[ "$platform" == "Darwin" ]]; then elif [[ "$platform" == "Darwin" ]]; then
if [[ -z "$AUTO_NOTIFY_SOUND" ]]; then notification_command="display notification (item 1 of argv) with title (item 2 of argv)"
osascript \ notification_body=($body $title)
-e 'on run argv' \ if [[ ! -z "$AUTO_NOTIFY_SOUND" ]]; then
-e 'display notification (item 1 of argv) with title (item 2 of argv)' \ notification_command+=" sound name (item 3 of argv)"
-e 'end run' \ notification_body+=("$AUTO_NOTIFY_SOUND")
"$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"
fi fi
osascript \
-e 'on run argv' \
-e ${notification_command[@]} \
-e 'end run' \
${notification_body[@]}
else else
printf "Unknown platform for sending notifications: $platform\n" printf "Unknown platform for sending notifications: $platform\n"
printf "Please post an issue on gitub.com/MichaelAquilina/zsh-auto-notify/issues/\n" printf "Please post an issue on gitub.com/MichaelAquilina/zsh-auto-notify/issues/\n"