How to use change desktop wallpaper using Python in Ubuntu 14.04 (with Unity)
Question: I tried this code:

    
    
    import os
    os.system("gsettings set org.gnome.desktop.background picture-uri file:///home/user/Pictures/wallpapers/X")
    

where `user` is my name and `X` is the picture.

But instead of changing the background to the given picture, it set the
default Ubuntu wallpaper.

What am I doing wrong?


Answer: First of all, make sure the file path is correct. Execute this line in a
terminal:

    
    
    ls /home/user/Pictures/wallpapers/X
    

Did the file get listed? If so, move on to the next step.

Make sure that you know where the `gsettings` command is. In the terminal,
run:

    
    
    which gsettings
    

That should get you the full path to `gsettings`. If nothing is displayed, the
directory containing `gsettings` isn't in [your `$PATH`
variable](http://stackoverflow.com/questions/14637979/how-to-permanently-set-
path-on-linux).

Let's say the path is `/usr/bin/gsettings`. Try to execute this in a terminal:

    
    
    /usr/bin/gsettings set org.gnome.desktop.background picture-uri /home/user/Pictures/wallpapers/X
    

If it works, pass the same string to `os.system()`:

    
    
    import os
    os.system("/usr/bin/gsettings set org.gnome.desktop.background picture-uri /home/user/Pictures/wallpapers/X")
    

