Ubuntu – The gsettings command line tool doesn’t change the background

backgroundcommand linewallpaper

I've been using elementary os for the last half a year and now I have installed the latest Ubuntu on my system. On elementary os, I was using this command to change the desktop background:

gsettings set org.gnome.desktop.background picture-uri file:///path_to_image

However, this command does not seem to do anything in Ubuntu. I can change the background by choosing a different image in the Appearance menu but I need to change the background from a script and hence the need for a working command.

When running the above command in a terminal no error is produced. If I run the gsetting get command, it returns the background image it always had, as if nothing happened. It totally ignores my set command. The images I tried this command on are the same images in the /usr/share/backgrounds images that are provided by default. Also, I changed the permissions of the entire background folder (and its contents) to be readable and writable to everyone to no avail.

I tried logging out and back in to see if it produces any changes to the background but nothing happens and even if it did, I wouldn't like to re-login every time the background changes…

Doing an online search yielded no results.

Thank you for your time!

Best Answer

gsettings apparently exits successfully if it could not write the setting:

$ chmod a-w .config/dconf/ -R
$ gsettings set org.gnome.desktop.background picture-uri file:///usr/share/backgrounds/Forever_by_Shady_S.jpg
$ echo $?

Either that is stunningly bad design, or a bug. Ensure that the ~/.config/dconf folder and everything in it is writable and owned by you:

sudo chown $USER:$USER ~/.config/dconf -R
chmod u+w ~/.config/dconf -R