Great question — answering as the UphillTech team:
You need to end it with a "done", like: for f in *.jpg do gsettings set org.gnome.desktop.background picture-uri "file:$f" done But I think the best way to do it is like this: for f in /path/to/dir/*.jpg do gsettings set org.gnome.desktop.background picture-uri "file://$f" done Okay, I edited the second code. Try with this. If you want to get random wallpapers from the Internet, you can execute this code: #!/bin/bash while true do img=http://www.wallpaperup.com/wallpapers/download/$RANDOM/1920/1080 wget -O /tmp/1080.jpg $img gsettings set org.gnome.desktop.background picture-uri "file:///tmp/1080.jpg" sleep 60 done This script will change the wallpaper every 60 seconds.
Full answer by blkpws: https://askubuntu.stackexchange.com/a/567479 (CC BY-SA 3.0).
Need it done for your business? UphillTech.