Last active
October 20, 2023 20:32
-
-
Save ruario/43fed207426aa88bcdb68cb2ff07eb50 to your computer and use it in GitHub Desktop.
Script to post every time a further 5% (1h12m) of the day is depleted.
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/sh -eu | |
# Minutes past the hour that could *potentially* be when a percentage lands, to be used as a | |
# simple cron tab entry. | |
# | |
# 0,12,24,36,48 * * * * [path]/dailycountdown.sh >/dev/null 2>&1 | |
# Define account username | |
PUBLISHER_USERNAME="[email protected]" | |
# βΉοΈ You need to have already setup auth for this user in toot TUI | |
# https://github.com/ihabunek/toot | |
# Check the time to see if it falls on 'round' percentages of the day | |
case "$(date '+%H%M')" in | |
"0000") PERCENTAGE_REMAINING="π©π©π©π©π©π©π©π©π©π© 100%" ;; | |
"0112") PERCENTAGE_REMAINING="π©π©π©π©π©π©π©π©π©π§ 95%" ;; | |
"0224") PERCENTAGE_REMAINING="π©π©π©π©π©π©π©π©π©β¬οΈ 90%" ;; | |
"0336") PERCENTAGE_REMAINING="π©π©π©π©π©π©π©π©π§β¬οΈ 85%" ;; | |
"0448") PERCENTAGE_REMAINING="π©π©π©π©π©π©π©π©β¬οΈβ¬οΈ 80%" ;; | |
"0600") PERCENTAGE_REMAINING="π©π©π©π©π©π©π©π§β¬οΈβ¬οΈ 75%" ;; | |
"0712") PERCENTAGE_REMAINING="π©π©π©π©π©π©π©β¬οΈβ¬οΈβ¬οΈ 70%" ;; | |
"0824") PERCENTAGE_REMAINING="π©π©π©π©π©π©π§β¬οΈβ¬οΈβ¬οΈ 65%" ;; | |
"0936") PERCENTAGE_REMAINING="π©π©π©π©π©π©β¬οΈβ¬οΈβ¬οΈβ¬οΈ 60%" ;; | |
"1048") PERCENTAGE_REMAINING="π©π©π©π©π©π§β¬οΈβ¬οΈβ¬οΈβ¬οΈ 55%" ;; | |
"1200") PERCENTAGE_REMAINING="π©π©π©π©π©β¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈ 50%" ;; | |
"1312") PERCENTAGE_REMAINING="π©π©π©π©π§β¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈ 45%" ;; | |
"1424") PERCENTAGE_REMAINING="π©π©π©π©β¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈ 40%" ;; | |
"1536") PERCENTAGE_REMAINING="π©π©π©π§β¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈ 35%" ;; | |
"1648") PERCENTAGE_REMAINING="π§π§π§β¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈ 30%" ;; | |
"1800") PERCENTAGE_REMAINING="π§π§π¨β¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈ 25%" ;; | |
"1912") PERCENTAGE_REMAINING="π§π§β¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈ 20%" ;; | |
"2024") PERCENTAGE_REMAINING="π§π¨β¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈ 15%" ;; | |
"2136") PERCENTAGE_REMAINING="π§β¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈ 10%" ;; | |
"2248") PERCENTAGE_REMAINING="π₯β¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈβ¬οΈ 5%" ;; | |
*) echo "The time does not fall on an interesting division of the day" >&2 ; exit 0 ;; | |
esac | |
# Post using toot TUI | |
echo -e "$(date --date='+1 hours' '+%F')\n${PERCENTAGE_REMAINING}" | toot post -u "$PUBLISHER_USERNAME" -v public |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment