Giter VIP home page Giter VIP logo

wallpaper-reddit's Introduction

NOTICE

I have not recently had the time to maintain and bug fix this project. Thus, I have put the repo into readonly mode. I am seeking for a developer that is willing to maintain this project and potentially implement new features. Please reach out to me at mkubiak dot dev at gmail dot com if you are interested in taking over the project and have good DevOps/Python experience. I'm happy to point to actively maintained forks, and someone could wrap up the v4 branch if they have time. It's very close to completion.

wallpaper-reddit

About

wallpaper-reddit is a Python 3 program that sets your wallpaper to the top image of one or multiple subreddits. Version 3 has introduced many changes, such as the removal of all external dependencies, automatic DE detection for wallpaper setting, and proper setup using setuptools.

Installation

RPMs for Fedora 23, Fedora 24, Ubuntu 16.04/Linux Mint 18 can be found on the [Releases Page] (https://github.com/markubiak/wallpaper-reddit/releases)

Users of Ubuntu derivatives <16.04 will have to build from source, as the version of PIL shipped with those versions of Ubuntu is outdated.

Arch users can get the package from the AUR

From Source:
1.) Install Pillow 3.x or the libraries necessary to compile it from scratch if the distribution you're using does not package it:

  • Ubuntu <16.04/Linux Mint 17/ElementaryOS: sudo apt-get install python3-dev python3-setuptools libjpeg8-dev zlib1g-dev libfreetype6-dev
  • Fedora: sudo dnf install python3-imaging (installed by default)
  • Arch: sudo pacman -S python-pillow
  • Mac OS X El Capitan: * xcode-select --install
    * pip install pillow

2.) Clone the repository and navigate into the directory with the setup.py file.
3.) Run sudo python3 setup.py install

Usage

The script is very simple to use. Simply type:

wallpaper-reddit [subreddits]

If no subreddits are specified, the script will default to the top image from the subs section of the config file. There are many, many more options, all of which you can see by typing:

wallpaper-reddit --help

Configuration

The config file is in ~/.config/wallpaper-reddit, and will be created automatically. Currently, the GNOME, XFCE, MATE, Unity, and Cinnamon Desktop Environments should be automatically detected and the program should set the wallpaper without any extra work. However, due to the varying nature of window managers, it is possible, even likely, that you may have to specify a custom command to set your wallpaper. The program will prompt you for this if this is the case; the exact command can be researched per desktop environment. If your desktop environment is not supported, please file an issue so that automatic support can be implemented for others.

Config Options:

  • minwidth and minheight set the minimum dimensions the program will consider a valid candidate for a wallpaper. If --resize is enabled, the script will resize the image to those dimensions before setting the wallpaper.
  • minratio is the minimal aspect ratio of the image. It is a float value of width/height of the image, for example 1.6 for 16:9 image.
  • maxlinks is the maximum number of links the script will go through before giving up.
  • resize does the same thing as the --resize flag. It is enabled by default.
  • random does the same thing as the --random flag.

Overlay Titles

The program has an option to overlay the title of the image directly onto the image itself, so using conky to constantly read the title of the image from ~/.wallpaper/title.txt is no longer necessary (although it still works, and is recommended if not using the "resize" option). This function is not enabled by default, but it can be enabled with either the --settitle command line flag or more permanently in the config under the [Title Overlay] section. There are five options for setting titles: size, x/y alignment, and x/y offset.

Overlay Title Configuration Options

Options for the overlay title can only be set in the config file. They are under the [Title Overlay] section.

  • titlesize sets the font height at which the title will be rendered, in pixels.
  • titlealignx sets the horizontal alignment of the title, and can be either left, center or right.
  • titlealigny sets the vertical alignment, and can be top or bottom.
  • titleoffsetx and titleoffsety allow you to set an additional offset from the edge of the image, in pixels.

Startup

If wallpaper-reddit is run with the --startup flag, the program will wait on an internet connection. Once startup is activated, the script will try to connect to Reddit to download new wallpaper upon startup. The default setting is an interval of 3 and 10 attempts, which means that the script will try to connect to Reddit every 3 seconds for up to 10 tries, giving a total of 30 seconds before the script gives up.

Startup Configuration Options

Options for the startup can only be set in the config file. They are under the [Startup] section.

  • interval describes the amount of time, in seconds, between wallpaper-reddit's attempts to procure new wallpaper.
  • attempts describes the number of attempts that will be made to connect to Reddit. After this number of attempts has failed, wallpaper-reddit will cease to try downloading wallpaper during the current startup.

Saving

If wallpaper-reddit is run with the --save flag, no wallpaper will be downloaded. The current wallpaper will be copied to the save directory, as specified in the config file (default is ~/Pictures/Wallpapers on Linux, ~/My Pictures/Wallpapers on Windows), and its title will be put into a titles.txt file inside the same directory.

Blacklists

There is a function to blacklist a certain wallpaper from the script if it is particularly ugly. Simply run the script with the --blacklist flag. The script will run as usual, but additionally blacklist your current wallpaper. You'll get a new wallpaper and never see the old one again.

External commands and wallpaper info

Because more information is always better, much more than the wallpaper itself exists in ~/.wallpaper.

  • blacklist.txt contains the urls of blacklisted wallpapers, one can manually add urls without issue.
  • url.txt is the url of the current wallpaper
  • title.txt is the title of the current wallpaper (useful if you want to put the title into conky)
  • external.sh is a bash script that is run at the end of every execution of the script (Linux only). Any extra commands to deal with the wallpaper can be safely placed in this bash script. I personally have mine darken my xfce4-panel if the wallpaper is too bright at the top, and set the wallpaper as my SLiM/xscreensaver background.

Contact

If there is an issue with the program, please file a GitHub issue. If you need more specific help troubleshooting a specific desktop or have an issue that isn't worthy of GitHub, feel free to reach out to me via email: mkubiak.dev at gmail dot com

wallpaper-reddit's People

Contributors

antoniovazquezblanco avatar ashwinvis avatar avano avatar cdglitch avatar chermnyx avatar clotifoth avatar eaguilera23 avatar markubiak avatar nickpesce avatar nicolasmaniotto avatar olivierbondu avatar orzarchi avatar qfulsher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

wallpaper-reddit's Issues

xfce setcommand

I was able to fix the "Your DE could not be detected to set the wallpaper." With the following

setcommand = xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/workspace0/last-image -s /home/####/.wallpaper/wallpaper.jpg

Where the backdrop is found following the instructions below:

To determine the correct location of the backdrop entry, run:
xfconf-query -c xfce4-desktop -m
...and then change the wallpaper using the normal desktop dialog (or thunar's "set as wallpaper"). This will show you which xfconf setting was changed to display the image. Adjust your script to use this location.
Thanks to -- numzob

and #### is replaced by your username.

Return status of os.system calls are not checked for successful execution.

When wallpaper-reddit runs the linux_wallpaper() call it doesn't check the return status of any of the os.system() calls. If there is an unsuccessful os.system() call then the program will still report that the command was run even though the verbose mode will print error messages for unrecognized arguments.

setting wallpaper in pop-os 20.04

There is problem in setting the wallpaper in pop-os 20.04. I attach the screenshot given below:

image

I solved it using adding the following command:


gsettings set org.gnome.desktop.background picture-uri file:////home/username/Pictures/Wallpapers/wallpaper.jpg

Crash on missing desktop environment

I assume this was introduced with #44

But apparently, DESKTOP_SESSION is None when using i3.

[sander@ATLPOR13 ~]$ wallpaper-reddit wallpapers
searching for valid images...
downloading https://i.imgur.com/kE2yyYK.jpg
Traceback (most recent call last):
  File "/usr/bin/wallpaper-reddit", line 11, in <module>
    load_entry_point('wallpaper-reddit==3.1.1', 'console_scripts', 'wallpaper-reddit')()
  File "/usr/lib/python3.7/site-packages/wpreddit/main.py", line 46, in run
    wallpaper.set_wallpaper()
  File "/usr/lib/python3.7/site-packages/wpreddit/wallpaper.py", line 25, in set_wallpaper
    linux_wallpaper()
  File "/usr/lib/python3.7/site-packages/wpreddit/wallpaper.py", line 40, in linux_wallpaper
    elif check_de(de, ["gnome", "gnome-xorg", "gnome-wayland", "unity", "ubuntu", "ubuntu-xorg", "budgie-desktop"]):
  File "/usr/lib/python3.7/site-packages/wpreddit/wallpaper.py", line 31, in check_de
    return any([de in current_de for de in list_of_de])
  File "/usr/lib/python3.7/site-packages/wpreddit/wallpaper.py", line 31, in <listcomp>
    return any([de in current_de for de in list_of_de])
TypeError: argument of type 'NoneType' is not iterable

UnicodeEncodeError encountered upon image title encode/decoding

(wily)clotifoth@localhost:~/Scripts$ wallpaper-reddit --random -f
searching for valid images...
downloading http://i.imgur.com/srVjTsG.jpg
Traceback (most recent call last):
  File "/usr/local/bin/wallpaper-reddit", line 9, in <module>
    load_entry_point('wallpaper-reddit==3.0.0', 'console_scripts', 'wallpaper-reddit')()
  File "/usr/local/lib/python3.4/dist-packages/wallpaper_reddit-3.0.0-py3.4.egg/wpreddit/main.py", line 29, in run
  File "/usr/local/lib/python3.4/dist-packages/wallpaper_reddit-3.0.0-py3.4.egg/wpreddit/download.py", line 73, in save_info
UnicodeEncodeError: 'ascii' codec can't encode characters in position 55-56: ordinal not in range(128)

This looks like comes back to this call at line 69 def save_info, download.py

    title = title.encode('utf-8').decode('unicode-escape')

The image proceeded to download and set as wallpaper correctly, but title.txt was completely empty.

It looks like this was the image in question: https://www.reddit.com/r/EarthPorn/duplicates/458b9a/strokkur_geyser_iceland_the_moment_of_eruption_oc/

I figured perhaps it was an Icelandic character getting dropped but the title here doesn't appear to have any of those...

Xfce-Desktop Wallpaper update doesn't work with multiple workspaces

Hi, this is what I get when I try to update my wallpaper using wallpaper-reddit:

wallpaper-reddit getmotivated
searching for valid images...
downloading http://imgur.com/xclHvfN.jpg
Property "/backdrop/screen0/monitor0/image-show" does not exist on channel "xfce4-desktop". If a new property should be created, use the --create option.
Property "/backdrop/screen0/monitor0/image-path" does not exist on channel "xfce4-desktop". If a new property should be created, use the --create option.
wallpaper set command was run

I'm using Arch Linux. Apparently instead of the /backdrop/screen0/monitor0/image-path property, there is a backdrop/screen0/monitor0/workspace0/last-image property which doesn't work.

A manual fix was to locate the ~/.wallpaper folder and use that as the desktop wallpaper folder setting.

Automatic configuration of setcommand doesn't work on Lubuntu

Using Lubuntu 16.06 the setcommand configuration field isn't automatically set. The command to change a wallpaper is pcmanfm -w /path/to/image. I also think there should be some better docs for how to add your own set command to the configuration file. Otherwise you have to dig around the code to figure out how the command gets interpreted.

ascii in download should be utf8

downloading https://i.redd.it/19mq572los811.jpg Traceback (most recent call last): File "/usr/bin/wallpaper-reddit", line 11, in <module> load_entry_point('wallpaper-reddit==3.1.1', 'console_scripts', 'wallpaper-reddit')() File "/usr/lib/python3.6/site-packages/wpreddit/main.py", line 45, in run download.save_info(valid) File "/usr/lib/python3.6/site-packages/wpreddit/download.py", line 71, in save_info titleinfo.write(remove_tags(link[1])) UnicodeEncodeError: 'ascii' codec can't encode characters in position 39-40: ordinal not in range(128)

Simplify installation instructions (OSX)

Have noticed that setup.py install is automatically pulling in Pillow from pip:

Processing dependencies for wallpaper-reddit==3.1.1
Searching for Pillow==4.3.0
Best match: Pillow 4.3.0
Adding Pillow 4.3.0 to easy-install.pth file

Using /usr/local/lib/python3.6/site-packages
Searching for olefile==0.44
Best match: olefile 0.44
Adding olefile 0.44 to easy-install.pth file

Using /usr/local/lib/python3.6/site-packages
Finished processing dependencies for wallpaper-reddit==3.1.1

Could you simply the install instructions by placing xcode-select --install into setup.py, and just have the user run setup.py install instead?

Make the script XDG Compliant

According to XDG Base Directory Specification

There is a single base directory relative to which user-specific data files should be written. This directory is defined by the environment variable $XDG_DATA_HOME.
There is a single base directory relative to which user-specific non-essential (cached) data should be written. This directory is defined by the environment variable $XDG_CACHE_HOME.
$XDG_DATA_HOME defines the base directory relative to which user specific data files should be stored. If $XDG_DATA_HOME is either not set or empty, a default equal to $HOME/.local/share should be used.
$XDG_CACHE_HOME defines the base directory relative to which user specific non-essential data files should be stored. If $XDG_CACHE_HOME is either not set or empty, a default equal to $HOME/.cache should be used.

Instead of making a ~/.wallpaper directory inside one's home directory, I suggest creating this folder in either ~/.local/share/wallpaper/ or ~/.cache/wallpaper/, and possibly also check if $XDG_DATA_HOME is defined and if it is use it.

DE detection needs some change in logic

At least in ArchLinux:

» echo $DESKTOP_SESSION 
/usr/share/xsessions/gnome

Which means this won't work:

elif de in ["gnome", "gnome-xorg", "gnome-wayland", "unity", "ubuntu", "budgie-desktop"]:

This can be simply fixed as:

...
elif check_de(de, ["gnome", "gnome-xorg", "gnome-wayland", "unity", "ubuntu", "budgie-desktop"]): 
...

def check_de(current_de, list_of_de):
    return any([de in current_de for de in list_of_de])

Not enough data to read image dimensions

Identify is having problems with reading the image dimensions for many images when only supplied with the first 1000 bytes (the error is "identify: no decode delegate for this image format `' @ error/constitute.c/ReadImage/501"). Increasing the request size in check_dimensions() solves the problem. I am unsure how much is needed to cover all cases, but 4096 bytes appears to work fine.

missing argument for -s

~$ wallpaper-reddit -f
searching for valid images...
downloading https://i.imgur.com/0udxARe.jpg
Option parsing failed: Missing argument for -s.
Command to set wallpaper returned non-zero exit code. Please file an issue or check your custom command if you have set one in the configuration file.

on xubuntu 18.04
dual monitor
installed with the deb

Configuration file is not used in i3

Hi, i am trying to set up wallpaper-reddit in Arch i3, all is working great but sadly i can't force it to use config '~/.config/wallpaper-reddit/wallpaper-reddit.conf'. Have you maybe consider adding an optional argument like '-c --config' to specify manually path to the configuration file?
or maybe is there some workaround?
Love your work and sorry for trouble :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.