diff options
Diffstat (limited to 'hooks/on_done')
| -rwxr-xr-x | hooks/on_done | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/hooks/on_done b/hooks/on_done new file mode 100755 index 0000000..955cd13 --- /dev/null +++ b/hooks/on_done @@ -0,0 +1,31 @@ +#!/bin/sh +# ttym on_done -- runs when a countdown reaches zero. +# +# $1 mode always "countdown" (a stopwatch never completes) +# $2 seconds the full duration that elapsed +# $3 comment the -c text, or an empty string +# +# timer waits for this to exit before ringing the bell and entering the +# alert loop, so background anything slow. + +seconds=$2 comment=$3 +mins=$((seconds / 60)) + +# Desktop notification. Gives the base build what the notify patch adds. +if command -v notify-send > /dev/null 2>&1; then + notify-send -u critical "Timer" "${mins}m done${comment:+ -- $comment}" & +fi + +# A sound, first player that exists wins. Backgrounded so it never blocks. +for player in paplay aplay mpv ffplay; do + if command -v "$player" > /dev/null 2>&1; then + sound=/usr/share/sounds/freedesktop/stereo/complete.oga + [ -r "$sound" ] && "$player" "$sound" > /dev/null 2>&1 & + break + fi +done + +# Push to your phone (uncomment and set your topic): +# curl -fsS -d "${mins}m done${comment:+ -- $comment}" ntfy.sh/your-topic & + +wait |
