Skip to content

Instantly share code, notes, and snippets.

@joeheyming
Last active August 29, 2015 14:17
Show Gist options
  • Save joeheyming/582f8d394e18b115d16f to your computer and use it in GitHub Desktop.
Save joeheyming/582f8d394e18b115d16f to your computer and use it in GitHub Desktop.
Shell script that updates a user's wallpaper and login screen on a mac
#!/bin/bash
wallpapers=`curl -s http://www.reddit.com/r/wallpapers.rss | grep -Eo 'http://i.imgur.com[^&]+jpg'`
papers=($wallpapers)
num_wallpapers=${#papers[*]}
# grab 2 random wallpapers for desktop1 and desktop2
for x in `seq 1 2`; do
url=`echo -n "${papers[$((RANDOM%num_wallpapers))]}"`
curl $url -s > ~/Pictures/background$x.jpg
done;
# add this line for updating the login screen on yosemite:
cp ~/Pictures/background1.jpg /Library/Caches/com.apple.desktop.admin.png
# After running this script once, in your mac settings, point desktop 1 to ~/Pictures/background1.jpg
# point desktop 2 to ~/Pictures/background2.jpg
# Then set the picture to change every 30 minutes
# Then put this in crontab: 0 * * * * /Users/$USER/scripts/randomWallpaper.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment