Last active
January 4, 2016 17:29
-
-
Save fdv/8654557 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 | |
KITTEN_SITE_URL="http://emergencykitten.com" | |
KITTEN_IMG_FILE=kitten.jpg | |
KITTEN_SECS=$1 | |
usage(){ | |
echo "Usage : $(basename $0) <sleep_time>" | |
echo "Exemple : $(basename $0) 60" | |
exit 1 | |
} | |
# Check sleep time arg # | |
[[ ! $1 =~ [0-9]+ ]] && usage | |
while true; do | |
# Get image URL # | |
kitten_img_url=$(curl -s -XGET ${KITTEN_SITE_URL} | grep 'kitten-image' | cut -d'"' -f4) | |
# Retrieve image (following redirect) # | |
curl -s -o ${KITTEN_IMG_FILE} -L -XGET ${KITTEN_SITE_URL}/${kitten_img_url} | |
# Change wallpaper # | |
#defaults write com.apple.desktop Background "{default = {ImageFilePath = '${PWD}/${KITTEN_IMG_FILE}'; };}" | |
osascript -e "set desktopImage to POSIX file \"${PWD}/${KITTEN_IMG_FILE}\" | |
tell application \"Finder\" | |
set desktop picture to desktopImage | |
end tell" | |
sleep ${KITTEN_SECS} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment