Skip to content

Instantly share code, notes, and snippets.

@augbog
Last active August 2, 2017 20:47
Show Gist options
  • Save augbog/9d47de4b9ed881844c7d to your computer and use it in GitHub Desktop.
Save augbog/9d47de4b9ed881844c7d to your computer and use it in GitHub Desktop.
CURL imgur links from a subreddit every so often so you always have a variety of wallpapers :)
#!/bin/bash
cd ~/Pictures/wallpapers && curl https://www.reddit.com/r/wallpapers/ | tr '"' '\n' | grep imgur | tee "$$.tmp" | egrep 'http:\/\/i.imgur.com\/.*\.jpg' | xargs wget -q -nc
egrep '^http://imgur.com/a/' "$$.tmp" | xargs -L1 ~/Pictures/wallpapers/imgur_album_download.sh
rm "$$.tmp"
# Credit /u/Molozonide
# https://www.reddit.com/r/wallpapers/comments/138qi2
PATH=/bin:/usr/bin:/usr/local/bin
0 10 * * * /Users/USER/Pictures/wallpapers/redditwallpapers.sh &> /dev/null
#!/bin/bash
curl "$1" \
| grep 'thumb-title' \
| sed 's/^.*data-src="//' \
| sed 's/" data-index=".*>$//' \
| sed 's/s././' \
| xargs -L1 wget -q -nc
# Credit /u/Molozonide
# https://www.reddit.com/r/wallpapers/comments/138qi2

Reddit Wallpapers

A script that will pull from reddit.com/r/wallpapers so you always have variety.

Credit goes to /u/Molozonide who supplied the script :D I just fixed it up and put it nicely in one place.

Install

  1. Go to terminal and cd ~/Pictures/ && mkdir wallpapers so you have a place for your wallpapers
  2. Take the files redditwallpapers.sh and imgur_album_download.sh and move them to ~/Pictures/wallpapers
  3. In terminal edit your cron jobs by doing crontab -e and editing the file to have the following:
PATH=/bin:/usr/bin:/usr/local/bin

0 10 * * * /Users/USER/Pictures/wallpapers/redditwallpapers.sh &> /dev/null

This will set it up so that it runs everyday at 10 AM. I also set it up so it won't mail you. Also note it's important to have a newline at the end of cron.

  1. Verify that the cron job is running by doing crontab -l
  2. Go to your Desktop, select Change Desktop Background...
  3. In the bottom right hit the + button, select the wallpapers folder and then check Change picture interval.

Note: If you get Permission denied for running redditwallpapers.sh or imgur_album_download.sh, you may need to change the permissions (chmod 777)

Customize

  • If you want to customize the /wallpapers directory, just remember to update redditwallpapers.sh
  • You can also customize the subreddit to pull from by changing the curl url

Other awesome subreddits to pull from

@scorpionhiccup
Copy link

On running the script, I'm getting wget: missing URL

@augbog
Copy link
Author

augbog commented Oct 14, 2015

@scorpionhiccup when you say running the script, are you running redditwallpapers.sh or are you running imgur_album_download.sh? You have to run redditwallpapers.sh which calls the latter (ideally I should just merge this into one file -- will do that some time when I can)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment