Ubuntu 12.04 automatically switches the desktop background. Previously, gconftool was used in gnome2 to change the desktop background of ubuntu. After installing 12.04, I found that it could not work. I studied it and switched to gsettings. I uninstalled unity and installed gnome-panel desktop. the script is as follows: [cpp] #! /Bin/bash confFile = ". switchbg. conf "cd $ (dirname $0) filepath = $ PWD find $ filepath | grep-E ". jpg $ |. png $ |. JPG $ |. PNG $ "> $ confFile cnt = 'cat $ confFile | wc-l' while true do line =$ ($ RANDOM % $ cnt + 1 )) bgfile = $ (head-n $ line $ confFile | tail-n 1) bgfile = "'file: // $ bgfile '" bkfile = $ (gsettings get org. gnome. desktop. background picture-uri) echo $ bkfile echo $ bgfile if [$ bkfile! = $ Bgfile] then break fi done gsettings set org. gnome. desktop. background picture-uri $ bgfile rm-f $ confFile is saved and added to crontab. It is found that the gsettings set of the script does not work. so you can only change it: [cpp] #! /Bin/bash confFile = ". switchbg. conf "changedtime = 600 cd $ (dirname $0) filepath = $ PWD find $ filepath | grep-E ". jpg $ |. png $ |. JPG $ |. PNG $ "> $ confFile cnt = 'cat $ confFile | wc-l' while true do line =$ ($ RANDOM % $ cnt + 1 )) bgfile = $ (head-n $ line $ confFile | tail-n 1) bgfile = "'file: // $ bgfile '" bkfile = $ (gsettings get org. gnome. desktop. background picture-uri) if [$ bkfile! = $ Bgfile] then break fi done gsettings set org. gnome. desktop. background picture-uri $ bgfile> tmp. log sleep $ changedtime done rm-f $ confFile let the script automatically load at startup. you can modify the value of changedtime at the interval, in seconds.