auto-notify.plugin.zsh aktualisiert
Changed Plugin to use ntfy instead of notify-send, to send events to phone. Signed-off-by: eeleater <nikolasweger@googlemail.com>
This commit is contained in:
parent
27c07dddb4
commit
63f70f3c33
1 changed files with 13 additions and 30 deletions
|
@ -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 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="critical"
|
||||
transient=""
|
||||
urgency="high"
|
||||
icon=${AUTO_NOTIFY_ICON_FAILURE:-""}
|
||||
fi
|
||||
|
||||
local arguments=("$title" "$body" "--app-name=zsh" "$transient" "--urgency=$urgency" "--expire-time=$AUTO_NOTIFY_EXPIRE_TIME")
|
||||
local arguments=("--title=$title" "--priority=$urgency" "$body")
|
||||
|
||||
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"
|
||||
fi
|
||||
ntfy publish zsh_events ${arguments[@]}
|
||||
}
|
||||
|
||||
function _is_auto_notify_ignored() {
|
||||
|
|
Loading…
Add table
Reference in a new issue