Created
March 27, 2018 08:31
-
-
Save nikcorg/8154924503fa91f8a04843cb8069c68a to your computer and use it in GitHub Desktop.
Inspirobot background images
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
#!/usr/bin/env bash | |
DUMP=/path_to_downloaded_images_storage_here | |
GENERATED_IMG_SRC=$(curl -s "http://inspirobot.me/api?generate=true") | |
if [ $? -eq 0 ]; then | |
BASENAME=$(basename $GENERATED_IMG_SRC) | |
OUT="$DUMP/$BASENAME" | |
TMP="/tmp/$BASENAME" | |
curl -s -o "$TMP" "$GENERATED_IMG_SRC" | |
if [ $? -eq 0 ]; then | |
MIME=$(file -b --mime-type $TMP) | |
if [[ $MIME == image/* ]]; then | |
mv "$TMP" "$OUT" | |
osascript -e 'tell application "System Events" to set picture of every desktop to ("'$OUT'" as POSIX file as alias)' | |
fi | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment