Compare commits
14 commits
fix/bad-ic
...
master
Author | SHA1 | Date | |
---|---|---|---|
f6c1f7fa35 | |||
86deef4ded | |||
81f5161390 | |||
e9ca099379 | |||
0a2b2f4601 | |||
8a328a37bd | |||
63f70f3c33 | |||
|
27c07dddb4 | ||
|
76a527a66b | ||
|
a79a412f3a | ||
|
837b81de92 | ||
|
6e5a54c5b5 | ||
|
43dbc4eb56 | ||
|
055a5fa8ae |
2 changed files with 29 additions and 35 deletions
|
@ -1,6 +1,14 @@
|
|||
Changelog for zsh-auto-notify
|
||||
=============================
|
||||
|
||||
0.10.2
|
||||
------
|
||||
* Use preferable array argument expansion for flexible parameters
|
||||
|
||||
0.10.1
|
||||
------
|
||||
* Fix regression where not setting icon on Linux would cause issues (#59 #58)
|
||||
|
||||
0.10.0
|
||||
-----
|
||||
* Allow specifying an icon with notify-send backends
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export AUTO_NOTIFY_VERSION="0.10.0"
|
||||
export AUTO_NOTIFY_VERSION="0.10.2"
|
||||
|
||||
# Time it takes for a notification to expire
|
||||
[[ -z "$AUTO_NOTIFY_EXPIRE_TIME" ]] &&
|
||||
|
@ -7,6 +7,9 @@ export AUTO_NOTIFY_VERSION="0.10.0"
|
|||
[[ -z "$AUTO_NOTIFY_THRESHOLD" ]] &&
|
||||
export AUTO_NOTIFY_THRESHOLD=10
|
||||
|
||||
[[ -z "$AUTO_NOTIFY_PUBLISH" ]] &&
|
||||
export AUTO_NOTIFY_PUBLISH="zsh_events"
|
||||
|
||||
# List of commands/programs to ignore sending notifications for
|
||||
[[ -z "$AUTO_NOTIFY_IGNORE" ]] &&
|
||||
export AUTO_NOTIFY_IGNORE=(
|
||||
|
@ -41,40 +44,30 @@ 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_BODY="$(echo -e "Total time: %elapsed seconds\nExit code: %exit_code")"
|
||||
local DEFAULT_TITLE="ZSH: '%command' finished"
|
||||
local DEFAULT_BODY="$(echo -e "Time: %elapsed seconds elapsed\nExit code: %exit_code")"
|
||||
local DEFAULT_PUBLISH="zsh_events"
|
||||
|
||||
local title="${AUTO_NOTIFY_TITLE:-$DEFAULT_TITLE}"
|
||||
local text="${AUTO_NOTIFY_BODY:-$DEFAULT_BODY}"
|
||||
local publish="${AUTO_NOTIFY_PUBLISH:-$DEFAULT_PUBLISH}"
|
||||
|
||||
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="3"
|
||||
local icon=${AUTO_NOTIFY_ICON_SUCCESS:-""}
|
||||
if [[ "$exit_code" != "0" ]]; then
|
||||
urgency="critical"
|
||||
transient=""
|
||||
# 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="4"
|
||||
icon=${AUTO_NOTIFY_ICON_FAILURE:-""}
|
||||
fi
|
||||
if [[ -n "$icon" ]]; then
|
||||
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
|
||||
|
||||
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
|
||||
local arguments=("--title='$title'" "--priority=$urgency" $publish "$body")
|
||||
|
||||
ntfy publish -q ${arguments[@]}
|
||||
}
|
||||
|
||||
function _is_auto_notify_ignored() {
|
||||
|
@ -173,11 +166,4 @@ function enable_auto_notify() {
|
|||
|
||||
_auto_notify_reset_tracking
|
||||
|
||||
|
||||
platform="$(uname)"
|
||||
if [[ "$platform" == "Linux" ]] && ! type notify-send > /dev/null; then
|
||||
printf "'notify-send' must be installed for zsh-auto-notify to work\n"
|
||||
printf "Please install it with your relevant package manager\n"
|
||||
else
|
||||
enable_auto_notify
|
||||
fi
|
||||
|
|
Loading…
Add table
Reference in a new issue