Skip to content

Instantly share code, notes, and snippets.

@nikcorg
Created March 27, 2018 08:31
Embed
What would you like to do?
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