This script downloads wallpapers from various subreddits on Reddit.com, and saves them in a directory of your choice. The user can choose which subreddit to download the wallpapers from or enter a custom subreddit of choice. which technically makes this a reddit-random-image-downloader (.❛ᴗ❛.)
,And how many wallpapers or posts they want to download.
Install these dependencies if you don't already have them installed.
- curl
- jq
- Clone this repository or download the
reddit-wallpaper-downloader.sh
file. - Make the file executable with the command
chmod +x reddit-wallpaper-downloader.sh
. - Run the script with the command
./reddit-wallpaper-downloader.sh
. - Enter the number of wallpapers you want to download when prompted.
- The downloaded wallpapers will be saved in the
$HOME/Pictures/Wallpapers
directory (or the directory specified by the$WALLPAPER_PATH
environment variable).
- The script sends a request to the Reddit API to get the JSON data for the latest posts in the selected subreddit , limited to 100 posts at a time.
- The script then randomly picks a post from the returned JSON data that has an image link hosted on i.redd.it, reddit.com, or i.imgur.com.
- If the post is a gallery, it randomly selects an image from the gallery.
- The script fetches the image link and saves it as a .jpg file with a filename that includes the date and time the image was downloaded, as well as the title of the post.
This script is designed to download wallpapers from Reddit, but there are a few caveats you should be aware of.
The script only retrieves the 100 most recent wallpapers from the API to choose from. This means that if you run the script multiple times without deleting the images it previously downloaded, it may end up re-downloading the same images.
In some cases, the script may encounter a parse error due to issues with the cached JSON file in /tmp/
. To solve this issue, simply delete the JSON file and then re-run the script.
This script is licensed under the GPL-3.0 License. See the LICENSE file for more information.