Closed relentless-coder closed 5 years ago
yup, this is true. the background image did not change automatically with crontab configuration, but only worked with manual run on terminal. why?
cron only has access to a very restricted set of environment variables - the python script here makes use of one that is not available in that case.
see SO answer here: https://stackoverflow.com/questions/10374520/gsettings-with-cron/19666729#19666729
Hey,
I tried and experienced the problem myself as well, although I didn't encounter it before (not sure if they changed the behaviour of services [if not, then how did it work for so long?]).
Anyway, not only the script makes use of environment variables but also gsettinngs
(on $DISPLAY
) which himawaripy heavily relies on. I'm trying to find a way without hard-coding environment variables, but it might be our last resort.
i have managed to fix this issue as a walk-around approach. basically, the link that @ngrande shared above helped a lot.
that is, i have created a separate shell script as the below, and added in my crontab with the same period as the himawaripy executable file. this seemed to work very well so far.
#!/bin/bash
# http://bit.ly/2ines3u
# Wallpaper's directory.
dir="${HOME}/.cache/himawaripy/"
# export DBUS_SESSION_BUS_ADDRESS environment variable
PID=$(pgrep gnome-session)
export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ | cut -d= -f2-)
# Random wallpaper.
wallpaper=`find "${dir}" -type f | shuf -n1`
# Change wallpaper.
# http://bit.ly/HYEU9H
gsettings set org.gnome.desktop.background picture-options "spanned"
gsettings set org.gnome.desktop.background picture-uri "file://${wallpaper}"
above approach by @soohyunc is totally working. One suggestion is to change the "spanned" to "scaled" in order to center the image.
Thanks!
@soohyunc answer should be in README
. Thank you!
Fixed! You should now be able to use it as described in the README without any additional scripts. Let me know if you have any further questions. =)
OR PID=$(pgrep gnome-session | head -n1)
I followed every step as described in the installation process, but nothing happened. The is installed, I have looked into the directory, but the desktop background didn't change.