diff --git a/auto-notify.plugin.zsh b/auto-notify.plugin.zsh index 591a47e..d70cf79 100644 --- a/auto-notify.plugin.zsh +++ b/auto-notify.plugin.zsh @@ -41,7 +41,7 @@ function _auto_notify_message() { local exit_code="$3" local platform="$(uname)" # Run using echo -e in order to make sure notify-send picks up new line - local DEFAULT_TITLE="\"%command\" Completed" + local DEFAULT_TITLE="ZSH: \"%command\" Completed" local DEFAULT_BODY="$(echo -e "Total time: %elapsed seconds\nExit code: %exit_code")" local title="${AUTO_NOTIFY_TITLE:-$DEFAULT_TITLE}" @@ -50,36 +50,19 @@ function _auto_notify_message() { title="$(_auto_notify_format "$title" "$command" "$elapsed" "$exit_code")" body="$(_auto_notify_format "$text" "$command" "$elapsed" "$exit_code")" - if [[ "$platform" == "Linux" ]]; then - local urgency="normal" - local transient="--hint=int:transient:1" - 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 - # need to make the notification persistent. - if [[ "$exit_code" != "0" ]] && [[ "$exit_code" != "130" ]]; then - urgency="critical" - transient="" - icon=${AUTO_NOTIFY_ICON_FAILURE:-""} - fi - - local arguments=("$title" "$body" "--app-name=zsh" "$transient" "--urgency=$urgency" "--expire-time=$AUTO_NOTIFY_EXPIRE_TIME") - - if [[ -n "$icon" ]]; then - arguments+=("--icon=$icon") - fi - notify-send ${arguments[@]} - - elif [[ "$platform" == "Darwin" ]]; 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 - printf "Unknown platform for sending notifications: $platform\n" - printf "Please post an issue on gitub.com/MichaelAquilina/zsh-auto-notify/issues/\n" + local urgency="default" + 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 + # need to make the notification persistent. + if [[ "$exit_code" != "0" ]] && [[ "$exit_code" != "130" ]]; then + urgency="high" + icon=${AUTO_NOTIFY_ICON_FAILURE:-""} fi + + local arguments=("--title=$title" "--priority=$urgency" "$body") + + ntfy publish zsh_events ${arguments[@]} } function _is_auto_notify_ignored() {