Skip to content

Instantly share code, notes, and snippets.

@nikcorg
Created March 27, 2018 08:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikcorg/8154924503fa91f8a04843cb8069c68a to your computer and use it in GitHub Desktop.
Save nikcorg/8154924503fa91f8a04843cb8069c68a to your computer and use it in GitHub Desktop.
Inspirobot background images
#!/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