#!/bin/bash
# Author: Theodore Zacharia
# V0.1 - 08/02/2021 - Got so lazy WFH, needed computer script to remind me to exercise
#
# 10 10,11,12,13,14,15,16 * * 1,2,3,4,5 ./tools/doexercise.sh
# 10 10,11,12,13,14,15,16 * * 1,2,3,4,5 (export DISPLAY=:0 ; notify-send -t 120000 "reminder" "Do exercise at `date`")
# 10 10,11,12,13,14,15,16 * * 1,2,3,4,5 (export DISPLAY=:0 ; zenity --info --text="Do exercise at `date`")
TRACE=0
VAREXTYPE=0

if [ $TRACE -gt 0 ] ; then echo "Running $0 at `date`" >> /tmp/doexercise.log ; fi

GENDER="Male"

# pick the area
AREA_LIST[0]="Chest"
AREA_LIST[1]="Shoulders"
AREA_LIST[2]="Traps"
AREA_LIST[3]="Biceps"
AREA_LIST[4]="Forearms"
AREA_LIST[5]="Abdominals"
AREA_LIST[6]="Quads"
AREA_LIST[7]="Calves"
AREA_LIST[8]="Traps_middle"
AREA_LIST[9]="Lats"
AREA_LIST[10]="Lowerback"
AREA_LIST[11]="Glutes"
AREA_LIST[12]="Hamstrings"

# pick the type
EXTYPE[0]="Exercises"
if [ $VAREXTYPE -gt 0 ]
then
	EXTYPE[1]="Stretches"
	EXTYPE[2]="Bodyweight"
	EXTYPE[3]="Dumbbells"
fi

SIZE=${#AREA_LIST[@]}
INDEX=$(($RANDOM % $SIZE))
TAREA=${AREA_LIST[$INDEX]}


SIZE=${#EXTYPE[@]}
INDEX=$(($RANDOM % $SIZE))
TEXTYPE=${EXTYPE[$INDEX]}

GOTOURL="https://musclewiki.com/${TEXTYPE}/${GENDER}/$TAREA/"
echo "$GOTOURL"

#exit 0

export DISPLAY=:0 ; notify-send -t 120000 "reminder" "Do exercise at `date` , see $GOTOURL"
EL=$?
if [ $EL -ne 0 ]
then
	echo "Problem 1 $EL with $0 at `date`" >> /tmp/doexercise.log
fi

export DISPLAY=:0 ; zenity --text-info --html --url="$GOTOURL"
EL=$?
if [ $EL -ne 0 ]
then
	echo "Problem 2 $EL with $0 at `date`" >> /tmp/doexercise.log
fi
