Last active
February 13, 2023 14:20
-
-
Save nshenry03/87377674714b313bd101e3907ecaa619 to your computer and use it in GitHub Desktop.
Cronjob to help keep track of water
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
0 9-19 * * 1-5 ${HOME}/.local/bin/drink-water.sh |
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 - | |
#=============================================================================== | |
# | |
# FILE: drink-water.sh | |
# | |
# USAGE: ./drink-water.sh | |
# | |
# DESCRIPTION: Make sure to drink enough water | |
# | |
# OPTIONS: --- | |
# REQUIREMENTS: --- | |
# BUGS: --- | |
# NOTES: --- | |
# AUTHOR: Nick Henry (NSH), hnicholas@vmware.com | |
# ORGANIZATION: VMware, Inc. | |
# CREATED: 2023-02-08 17:48:57 | |
# REVISION: --- | |
#=============================================================================== | |
set -o nounset # treat unset variables as errors | |
#=============================================================================== | |
# GLOBAL DECLARATIONS | |
#=============================================================================== | |
declare -rx SCRIPT=${0##*/} # the name of this script | |
declare -rx TIMEOUT=300 # seconds alert is shown | |
declare -rx OZ_WATER=$(( 32 * ( $(date +%H) - 8 ) )) | |
#=============================================================================== | |
# SANITY CHECKS | |
#=============================================================================== | |
if [ -z "$BASH" ] ; then | |
printf "$SCRIPT:$LINENO: run this script with the BASH shell\n" >&2 | |
exit 192 | |
fi | |
#=============================================================================== | |
# MAIN SCRIPT | |
#=============================================================================== | |
/opt/homebrew/bin/alerter \ | |
-title Water \ | |
-group water \ | |
-message "By now, you should have drinken ${OZ_WATER}oz of water" \ | |
-timeout ${TIMEOUT} | |
> /dev/null 2>&1 | |
#=============================================================================== | |
# STATISTICS / CLEANUP | |
#=============================================================================== | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment