Skip to content

Instantly share code, notes, and snippets.

@TRSGuy
Forked from cpebble/get_wallpaper.py
Last active February 8, 2018 12:59
Show Gist options
  • Save TRSGuy/aeed4690fd2db15e57d3cdf85342ebb3 to your computer and use it in GitHub Desktop.
Save TRSGuy/aeed4690fd2db15e57d3cdf85342ebb3 to your computer and use it in GitHub Desktop.
import praw, subprocess, pathlib
SUBREDDIT = "wallpapers"
pp = "{}/.prevwall".format(str(pathlib.Path.home())) # this is where the previously used wallpaper links are stored
previousImages = [] # This is where the urls of previously used images will be stored
r = praw.Reddit(client_id="",
client_secret="",
user_agent="WallpaperGrabber by /u/ParanoidBox")
allowedFormats = ['jpg', 'png']
urls = [post.url for post in r.subreddit(SUBREDDIT).hot(limit=5) if post.url.split(".")[-1] in allowedFormats and !(in previousImages)post.url]
subprocess.call(['feh', "--bg-fill", urls[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment