Created
March 8, 2022 03:10
-
-
Save dylan-sessler/a9b18f0223694b500a9a694ae487dd12 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script runs an exercise program with custom intervals and exercises. The | |
# goal is to make sticking to a recommended program as easy as typing in the | |
# alias to run the script. | |
# I expect that this will remove the amount of internal conflict for stopping | |
# the program early, cheating on the amount of time for each exercise, and just | |
# generally reduce the amount of internal noise experienced on a daily basis. I | |
# see this as a decision fatigue reduction technique. People like being told | |
# what to do (eg. group exercise class) - this is just a way to tell yourself | |
# what to do and decrease your decision making burden. | |
# Components: | |
# - Display current exercise with instruction anchors | |
# - Audio queues to warn of upcoming switch, when to switch, and what to switch to | |
main(){ | |
exercise wrist-flex-left "$WRIST_FLEX_INSTRUCTIONS" 15 | |
exercise wrist-flex-right "$WRIST_FLEX_INSTRUCTIONS" 15 | |
exercise wrist-flex-left "$WRIST_FLEX_INSTRUCTIONS" 15 | |
exercise wrist-flex-right "$WRIST_FLEX_INSTRUCTIONS" 15 | |
exercise prayer-stretch "$PRAYER_STRETCH_INSTRUCTIONS" 15 | |
exercise mirror-spider-push-ups "$MIRROR_SPIDER_PUSH_UPS_INSTRUCTIONS" 15 | |
exercise prayer-stretch "$PRAYER_STRETCH_INSTRUCTIONS" 15 | |
exercise shake-it-off "$SHAKE_IT_OFF_INSTRUCTIONS" 60 | |
exercise arm-yourself-left "$ARM_YOURSELF_INSTRUCTIONS" 15 | |
exercise arm-yourself-right "$ARM_YOURSELF_INSTRUCTIONS" 15 | |
figlet el-fin | |
spd-say "You did it! Great job." | |
} | |
display(){ | |
EXERCISE_TITLE=$1 | |
EXERCISE_INSTRUCTIONS=$2 | |
EXERCISE_DURATION=$3 | |
clear | |
figlet -c $EXERCISE_TITLE | |
echo "Exercise duration:" "$EXERCISE_DURATION" "seconds" | |
echo "$EXERCISE_INSTRUCTIONS" | |
} | |
exercise(){ | |
TITLE=$1 | |
INSTRUCTIONS=$2 | |
LENGTH_OF_TIME_SECONDS=$3 | |
COUNTDOWN_INTERVAL=3 | |
PRE_COUNTDOWN_INTERVAL=$(echo "$LENGTH_OF_TIME_SECONDS - $COUNTDOWN_INTERVAL" | bc) | |
display $TITLE "$INSTRUCTIONS" $LENGTH_OF_TIME_SECONDS | |
spd-say $TITLE | |
sleep $PRE_COUNTDOWN_INTERVAL | |
spd-say "Change incoming" | |
sleep $COUNTDOWN_INTERVAL | |
} | |
WRIST_FLEX_INSTRUCTIONS=$(cat <<EOF | |
- arms out in front of body | |
- palms up | |
- bend wrist towards floor with other hand | |
EOF | |
) | |
PRAYER_STRETCH_INSTRUCTIONS=$(cat <<EOF | |
- palms together in prayer | |
- start at chin | |
- lower slowly to waist stopping at gentle stretch | |
EOF | |
) | |
MIRROR_SPIDER_PUSH_UPS_INSTRUCTIONS=$(cat <<EOF | |
- palms together in prayer | |
- press to steeple | |
- repeat | |
EOF | |
) | |
SHAKE_IT_OFF_INSTRUCTIONS=$(cat <<EOF | |
- drop arms to sides | |
- shake like drying hands | |
EOF | |
) | |
ARM_YOURSELF_INSTRUCTIONS=$(cat <<EOF | |
- arm out in front of body | |
- palm facing floor | |
- other arm stretch down-facing palm at wrist as far as comfortable | |
EOF | |
) | |
printred() { | |
c_grey="\x1b[38;5;1m" | |
nc="\033[0m" | |
printf "${c_grey}%s${nc}\n" "$*" >&2 | |
} | |
die() { | |
printred "$@" >&2 | |
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then | |
exit ${1-1} | |
else | |
return ${1-1} | |
fi | |
} | |
# If executed as a script, instead of sourced | |
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then | |
set -euo pipefail | |
main "$@" | |
else | |
echo "${BASH_SOURCE[0]}" sourced >&2 | |
shopt -s expand_aliases # reset from source-harnessing | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment