Skip to content

Instantly share code, notes, and snippets.

@bag-man
Created October 19, 2016 18:36
Show Gist options
  • Save bag-man/c5fb675187440b2ca262b124587b27df to your computer and use it in GitHub Desktop.
Save bag-man/c5fb675187440b2ca262b124587b27df to your computer and use it in GitHub Desktop.
Select and set a random offensive wallpaper
import praw
import random
import os
from urllib.request import urlretrieve
r = praw.Reddit(user_agent='wallpapergrabber')
submissions = r.get_subreddit('offensive_wallpapers').get_hot()
urls = []
for post in submissions:
if (("1920x1080" in post.title) or ("1920 x 1080" in post.title)) and ("i.im" in post.url):
urls.append(post.url)
urlretrieve(urls[random.randint(0,len(urls))], 'image.jpg')
os.system('feh --bg-scale image.jpg')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment