Compare commits

..

14 commits

Author SHA1 Message Date
f6c1f7fa35 auto-notify.plugin.zsh aktualisiert 2024-09-16 22:58:04 +02:00
86deef4ded auto-notify.plugin.zsh aktualisiert 2024-09-16 20:39:21 +02:00
81f5161390 auto-notify.plugin.zsh aktualisiert 2024-09-16 20:37:27 +02:00
e9ca099379 auto-notify.plugin.zsh aktualisiert 2024-09-16 20:35:51 +02:00
0a2b2f4601 auto-notify.plugin.zsh aktualisiert 2024-09-16 20:30:57 +02:00
8a328a37bd auto-notify.plugin.zsh aktualisiert 2024-09-16 20:30:05 +02:00
63f70f3c33 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>
2024-09-16 20:20:39 +02:00
Michael Aquilina
27c07dddb4
Merge pull request #63 from Grafcube/ignore-130
Treat code 130 as success
2024-07-08 16:43:31 +01:00
Grafcube
76a527a66b
Add a comment explaining why 130 is treated as success 2024-07-08 19:53:44 +05:30
Grafcube
a79a412f3a
Treat code 130 as success 2024-06-16 00:21:26 +05:30
Michael Aquilina
837b81de92
bump version to 0.10.2 2024-05-13 11:12:38 +01:00
Michael Aquilina
6e5a54c5b5
use array argument expansion 2024-05-13 11:11:51 +01:00
Michael Aquilina
43dbc4eb56
bump version to 0.10.1 2024-05-13 10:54:40 +01:00
Michael Aquilina
055a5fa8ae
Merge pull request #61 from MichaelAquilina/fix/bad-icon-path
fix: correctly omit --icon from notify-send when not set
2024-05-13 11:53:56 +02:00
2 changed files with 29 additions and 35 deletions

View file

@ -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

View file

@ -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
enable_auto_notify