I am currently writing a script to change my desktop background every one minute, however when I pipe the output to a file I get:
** (process:22375): WARNING **: Command line `dbus-launch --autolaunch=134db3df26c562acad27e9cf00000009 --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n
The python script is as follows:
#!/usr/bin/env python
import os, random
def main():
files = os.listdir("/home/benkaiser/scripts/XKCD_IMAGES");
nameOfImg = random.choice(files)
os.system("gsettings set org.gnome.desktop.background picture-uri file:///home/benkaiser/scripts/XKCD_IMAGES/" + nameOfImg)
print "Finished Fine!";
return 0
if __name__ == '__main__':
main()
And the crontab command is:
* * * * * /home/benkaiser/scripts/changeDesktop.py
I have already made sure the file is executable so that is not the problem. It seems to be to do with the os.system call that gives the error
The problem is that
gsettingsneeds to know what screen to run on. If you run it in a terminal, it will run on the screen the terminal is on, but if you run it in crontab, it doesn’t have any screen in its context.You might be able to do this by adding a switch to the gsettings command, or an environment variable, to specify the display. It depends on whether gsettings was ever written to work in a situation where the display couldn’t be inferred.