blob: 441d6f115c58b01b8f7f86d3fe793d24ab0c4338 (
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
|
#!/bin/sh
# ttym on_start -- runs when a session begins.
#
# $1 mode countdown | stopwatch
# $2 seconds requested duration for a countdown, 0 for a stopwatch
# $3 comment the -c text, or an empty string
#
# stdin, stdout and stderr are /dev/null: printing here goes nowhere and
# cannot corrupt the redrawn progress line. timer waits for this to exit,
# so keep it quick or background the slow part with &.
mode=$1 seconds=$2 comment=$3
# Name the terminal window after what is running.
case $TERM in
xterm*|rxvt*|tmux*|screen*|alacritty|foot*)
if [ "$mode" = countdown ]; then
printf '\033]0;timer %sm %s\007' "$((seconds / 60))" "$comment" > /dev/tty
else
printf '\033]0;stopwatch %s\007' "$comment" > /dev/tty
fi
;;
esac
# Pause music while a countdown runs (uncomment to use):
# [ "$mode" = countdown ] && playerctl pause 2>/dev/null
|