Skip to content

Instantly share code, notes, and snippets.

@cpebble
Created January 30, 2018 09:45
Show Gist options
  • Save cpebble/cda41941786d295c01fd010a945db6d0 to your computer and use it in GitHub Desktop.
Save cpebble/cda41941786d295c01fd010a945db6d0 to your computer and use it in GitHub Desktop.
ReddidWallpaper
#!/usr/bin/python
import praw
import sys
import random
from pprint import pprint
import subprocess
SUBREDDIT = sys.argv[1] if len(sys.argv) > 1 else "offensive_wallpapers"
reddit = praw.Reddit(client_id='2RBn1ZOfEqZFkw',
client_secret='9sIGnCtbEd3Stio2v4_Nbljlh2g',
user_agent='Get these wallpapers(contact: christian@cpj.nu)')
Submissions = reddit.subreddit(SUBREDDIT).hot(limit=100)
wallpapers = [sub for sub in Submissions]
while True:
post = random.choice(wallpapers)
pprint(post.fullname)
if not "1920" in post.title or not "1080" in post.title:
print("Size not found in {}".format(post.title))
continue
print("Size found: {}".format(post.title))
accepted_format = False
for i in [".jpg", ".png"]:
if post.url[-4:]: accepted_format = True
if not accepted_format:
print("Format not accepted: {}".format(post.url))
continue
# If we got to here, then use the wallpaper as wallpaper
subprocess.call(["feh", "--bg-center", post.url])
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment