Ubuntu12.04 automatically switch the desktop background
Source: Internet
Author: User
Ubuntu12.04 automatically switches the desktop background. Previously, gconftool was used in gnome2 to change the ubuntu desktop background. 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] #... 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.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service