PC Games

Orb
Lasagne Monsters
Three Guys Apocalypse
Water Closet
Blob Wars : Attrition
The Legend of Edgar
TBFTSS: The Pandoran War
Three Guys
Blob Wars : Blob and Conquer
Blob Wars : Metal Blob Solid
Project: Starfighter
TANX Squadron

Android Games

DDDDD
Number Blocks
Match 3 Warriors

Tutorials

2D shoot 'em up
2D top-down shooter
2D platform game
Sprite atlas tutorial
Working with TTF fonts
2D adventure game
Widget tutorial
2D shoot 'em up sequel
2D run and gun
Roguelike
SDL 1 tutorials (outdated)

Latest Updates

SDL2 Rogue tutorial
Wed, 29th September 2021

SDL2 Gunner tutorial
Thu, 26th August 2021

SDL2 Shooter 2 tutorial
Tue, 13th July 2021

SDL2 Widget tutorial
Fri, 18th June 2021

SDL2 Adventure tutorial
Tue, 8th June 2021

All Updates »

Tags

android (3)
battle-for-the-solar-system (9)
blob-wars (9)
brexit (1)
code (6)
edgar (6)
games (37)
lasagne-monsters (1)
making-of (5)
match3 (1)
numberblocksonline (1)
orb (2)
site (1)
tanx (4)
three-guys (3)
three-guys-apocalypse (3)
tutorials (8)
water-closet (3)

Books

A Reddit Wallpaper download script

Fri, 27th May 2016

I like having new wallpapers, daily. As I most often got them from /r/wallpapers, I decided to write a small script to download them to use on my desktop. The script is rather straight forward. It will download the RSS feed from /r/wallpapers and extract the URLs of the first two jpgs that are listed within, which are then downloaded using wget. It will then resize them to better fit the desktop (some wallpapers are 4K, so I just resize them to my native resolution), and that's that.

Okay, there are a few extras: it will first check to see if we're online (by pinging Google), it will then only download new wallpapers if it's been at least 6 hours since the last check. Wallpapers older than two days old will be deleted before the new ones are fetched. Additionally, the user agent is set to be the latest version of Chrome, as Reddit has checks against rogue bots (note: if you run this script too often, your ip address could be banned - best to only run it once every few hours).

You can view the code below. Either copy and paste that into a file, or download the wallpaper.sh file at the bottom of this page. Remember to tweak it to suit your own needs (as a minimum, update the paths), and then chmod +x it before running.

#!/bin/bash -e

TMP="/tmp/wallpapers"
DIR="/path/to/wallpapers"
LASTDL="$DIR/.lastDownload"
UA=`/opt/google/chrome/chrome -version`

if ping -q -c 1 www.google.com

then

if [ ! -f $LASTDL ] || [ `find "$LASTDL" -mmin +360` ]

then

find "$DIR" -name '*.jpg' -mtime +2 -exec rm {} \;

mkdir -p $TMP

FILES=$(curl -A "$UA" https://www.reddit.com/r/wallpapers.rss | xmllint --format - | grep -Eo 'http[s]?:[^"]*jpg' | grep -v thumbs | head -2)

for FILE in $FILES
do
wget -c $FILE -P $TMP
done

touch $LASTDL

mogrify -resize 1920x "$TMP/*.jpg"

mv $TMP/*.jpg $DIR

fi

fi
Downloads: wallpaper.sh (0Kb)
 
code 

Related News

Orb source code
Sun, 25th April 2021

Lasagne Monsters source code
Mon, 19th April 2021

3 Guys Apocalypse source code
Sat, 10th April 2021

Scraping Amazon's Wishlist
Fri, 20th May 2016

Resizing an array in C
Wed, 18th May 2016

Comments

Share your comments and thoughts below. All comments are anonymous and cannot be edited.

 

Mobile site