Created
November 1, 2014 11:38
-
-
Save johnsto/c7e2445e24c4d8e56053 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 | |
# | |
# Prints the days remainig until Christmas onto an image and (optionally) | |
# sets it as the user's Twitter avatar. | |
avatar="avatar.png" | |
date="25 Dec" | |
user= | |
while getopts 'a:d:u:' flag; do | |
case "${flag}" in | |
a) avatar="${OPTARG}" ;; | |
d) date="${OPTARG}" ;; | |
u) user="${OPTARG}" ;; | |
*) error "Unknown argument ${flag}" ;; | |
esac | |
done | |
days="$(( $(date --date="$date" +%j) - $(date +%j) ))" | |
if [[ $days -lt 10 ]]; then | |
text="$days!" | |
else | |
text="$days" | |
fi | |
convert \ | |
-gravity SouthWest \ | |
-pointsize 72 \ | |
-stroke "#000" -strokewidth 2 -fill "#fff" -draw "text 0,0 '$text'" \ | |
$avatar tmp_$avatar | |
if [[ ! -z $user ]]; then | |
curl \ #-v --compressed \ | |
-X POST \ | |
-F "image=$(base64 -w0 tmp_$avatar)" \ | |
-u $user \ | |
"https://foauth.org/api.twitter.com/1.1/account/update_profile_image.json" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment