Created
January 30, 2016 20:31
-
-
Save peterhartree/cdf6b0c698434d21e2ff to your computer and use it in GitHub Desktop.
Create a new Beeminder datapoint if current system time is within a given window.
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
# Create a new Beeminder datapoint if current system time is within a | |
# given window. | |
# | |
# Possible use case: if you're on OS X, you can trigger this script with | |
# the free ControlPlane app. This means you can automatically Beemind | |
# yourself to a given location before a given time. | |
# | |
# Originally made by @peterhartree in order to Beemind his way to the | |
# office bright and early. Check up on him at | |
# https://www.beeminder.com/peterhartree/goals/rcu :P | |
####################################### | |
# Config | |
####################################### | |
username="REPLACE" | |
authToken="REPLACE" | |
goalSlug="REPLACE" | |
datapointValue="1" | |
datapointComment="Good+morning+everybody" | |
startTime="500" # 5am | |
endTime="745" # 7.45am | |
# If you want to specify e.g. 9.30pm, use the number "2145". | |
####################################### | |
# No need to edit below here. | |
####################################### | |
currentTime=`date +%k%M` | |
if [ $currentTime -gt $startTime -a $currentTime -lt $endTime ]; then | |
echo "Current time is within the specified window." | |
echo "Sending Beeminder datapoint." | |
curl --data "auth_token=$authToken&value=$datapointValue&comment=$datapointComment" https://www.beeminder.com/api/v1/users/$username/goals/$goalSlug/datapoints.json | |
exit 0 | |
else | |
echo "Nothing to do." | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment