#!/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