So I'm writing a bash script that pulls a background picture from the web and sets it as the desktop wallpaper. I've managed to change the desktop background which is fairly easy by just running

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

but this does not have the same effect as right clicking a photo and choosing "set as desktop background". Using the right click method the login screen background changes too, but using gsettings I can't get the login screen background to change.

I've read about pantheon-greeter and it's .conf files in /etc/lightdm, but I don't want to use that method because all those files need root permissions to be edited. Clearly, if I can just right click a picture and set it as background I don''t need root permissions. Can anyone help me find a way to do that using the terminal? Thanks.

1 Answer 1


Hopefully someone can answer with the correct way to do this via gsettings, but under the hood the wallpaper contract is actually provided by a handy script called set-wallpaper. The following will change the background for your user on the desktop and login screen:

set-wallpaper <image-path>

I've just tested this myself - no root permissions needed.

The corresponding code can be found here. I can see the call to gsettings, but can't see anything else being done (though I haven't looked too hard) - so I'm unsure why just setting it via gsettings doesn't work.

EDIT: There's a copy_for_greeter() method in there which copies the image to /var/lib/lightdm-data/$USER, so I guess gsettings does work, but you need to ensure that you copy the image to somewhere where LightDM can access it.

So if you want to do this via gsettings then the following should work:

cp <background-image> $XDG_GREETER_DATA_DIR
gsettings set org.gnome.desktop.background picture-uri file:/$XDG_GREETER_DATA_DIR/<background-image>

However set-wallpaper does all of this heavy-lifting for you, so I'd recommend using that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.