blob: 955cd131748c5b521d696d34163d6b8c3117aeaa (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
|