diff options
Diffstat (limited to 'hooks/on_start')
| -rwxr-xr-x | hooks/on_start | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/hooks/on_start b/hooks/on_start new file mode 100755 index 0000000..441d6f1 --- /dev/null +++ b/hooks/on_start @@ -0,0 +1,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 |
