#!/bin/sh [ "$1" = "info" ] && echo "calculate lap duration" && exit 2 lap="$1" break_rule() { break_interval=$1 break_duration=$2 if [ $(( $lap % $break_interval )) -eq $(( $break_interval - 1 )) ] ; then echo $break_duration exit 0 fi } break_rule 6 $(( 15 * 60 )) # every 6th lap (every 3rd break) is a 15 minute break break_rule 2 $(( 5 * 60 )) # every 2nd lap is a 5 minute break echo $(( 25 * 60 )) # every other lap is a normal 25 minute lap