ssimunic / Daily-Reddit-Wallpaper

Change your wallpaper to the most upvoted image of the day from /r/wallpapers or any other subreddit on system startup
http://ssimunic.github.io/Daily-Reddit-Wallpaper/
GNU General Public License v3.0
306 stars 51 forks source link

Script does not work as a cron job. #36

Closed jenroper closed 7 years ago

jenroper commented 7 years ago

It appears that when running this script as a cron job, the code falls through all of the desktop environment checks. The image is downloaded from reddit, but it never gets set as a wallpaper. Here's what I captured in my log.

Traceback (most recent call last): File "./change_wallpaper_reddit.py", line 205, in desktop_environment = detect_desktop_environment() File "./change_wallpaper_reddit.py", line 148, in detect_desktop_environment info = subprocess.getoutput("xprop -root _DT_SAVE_MODE") AttributeError: 'module' object has no attribute 'getoutput'

remggo commented 7 years ago

There is a similar issue #3 The problem is (i guess) that cron jobs are not user jobs and do not run "inside" your DE. This is all speculation. I personally do not use cron jobs and have no experience with them. But they are not spawned by the DE so it gets hard for the script to find your running DE.

Maybe you can add a parameter to the script to set the DE manually?

jenroper commented 7 years ago

I got it figured out. You need to set the environment variables that the script is looking for along with the DISPLAY environment variable. For example: export DISPLAY=:0 && export GNOME_DESKTOP_SESSION_ID=this-is-depricated

jenroper commented 7 years ago

I updated the readme file on my fork to have better instructions for using this script as a cron job.