Wednesday, May 20, 2009

Wallpaper changer script

Tired of changing wallpaper everyday? You will get many soft-wares which will change it for you everyday. The only thing which I dint like about them is, they put a picture which is stored on your computer. SO there is possibility that you have seen that picture before. What about a truly random pic??
Here is the script:

rm -f ~/wallpaper/w.jpg ~/wallpaper/widescreen_rss.php
wget -O ~/wallpaper/widescreen_rss.php http://www.mlewallpapers.com/widescreen_rss.php
wget -O ~/wallpaper/w.jpg `grep enclosure ~/wallpaper/widescreen_rss.php | cut -d \" -f 2`
gconftool-2 -t str --set /desktop/gnome/background/picture_filename ~/wallpaper/w.jpg

Put it in your cron so that it will execute daily. You can modify this to fetch picture from any site which will give new picture daily.


All this can be done using following :

mkdir -p ~/new_installation/wallpaper
cat > ~/new_installation/wallpaper/wallpaper_changer.sh << END
rm -f ~/new_installation/wallpaper/w.jpg ~/new_installation/wallpaper/widescreen_rss.php
wget -O ~/new_installation/wallpaper/widescreen_rss.php http://www.mlewallpapers.com/widescreen_rss.php
wget -O ~/new_installation/wallpaper/w.jpg \`grep enclosure ~/new_installation/wallpaper/widescreen_rss.php | cut -d \" -f 2\`
gconftool-2 -t str --set /desktop/gnome/background/picture_filename ~/new_installation/wallpaper/w.jpg
END
chmod a+x ~/new_installation/wallpaper/wallpaper_changer.sh
cat >> /etc/sudoers << END
# crontab root scripts
action-owl ALL=(ALL) NOPASSWD:~/new_installation/wallpaper/wallpaper_changer.sh
END

For fedora :

cat >> /var/spool/cron/root << END
0 12 * * * ~/new_installation/wallpaper/wallpaper_changer.sh >/dev/null 2>&1
END

For ubuntu :

cat >> /var/spool/cron/crontabs/root << END
0 12 * * * ~/new_installation/wallpaper/wallpaper_changer.sh >/dev/null 2>&1
END


This will change wallpaper on 12 noon every day.

No comments:

Post a Comment