Thursday, April 1, 2010

Change the desktop background using Perl script - GNOME (Fedora and Ubuntu)

Hi Guys,

These days people are opting Linux distributions like Fedora, Ubuntu, etc., for their PC's mainly to avoid malware and virus attacks. Bundling them with all kind of multimedia and entertainment tools make them more interesting and the fact that they are free make them further irresistible.

Many of the home users find them wanting. But there are small things that you would find irritating, say, something as simple as changing the desktop background. To make your life simple, here I have made a simple, sample perl script to change the desktop image. It will download pictures from National Geographic website and set it as your wallpaper. This is just a sample script, if you have the time please try it out with different website/urls. I am sure, you might as well start learning perl like I did... :-)

Note : If you want to run this script daily, just add an entry in the crontab. Crontab entry must be Xserver login user and not other users.

Here the script:-
-----------------

#!/usr/bin/perl

use WWW::Mechanize;

my $url  = "http://photography.nationalgeographic.com/photography/photo-of-the-day/";

my $mech  = WWW::Mechanize->new();
$mech->get( $url );
my @links = $mech->links();
my $download_link;

foreach my $link (@links)
{
   if  ($link->text() eq "Download Wallpaper (1600 x 1200 pixels)")
      {
       $download_link = $link->url();
       last;
      }
}

$uri = $download_link;
$date_time = localtime(time);
my @file_name = split(' ',$date_time);

#Picture will be stored in "/home/vivek/Pictures/" folder and file will be like this "Apr-1-2010.jpg"
#Change the path/folder...
 
$tempfile = "/home/vivek/Pictures/$file_name[1]-$file_name[2]-$file_name[4].jpg";

$mech->get( $uri, ':content_file' => $tempfile );


if ( -e $tempfile )
{
system("gconftool-2 --type string --set /desktop/gnome/background/picture_filename $tempfile");
}

-------------------

Important links:-

http://photography.nationalgeographic.com/photography/photo-of-the-day/
http://search.cpan.org/~petdance/WWW-Mechanize-1.60/lib/WWW/Mechanize.pm

24 comments:

Andy Lester said...

You don't have to search through the links yourself. Do this:

$download_link = $mech->find_link( text => 'Download Wallpaper (1600 x 1200 pixels)' );

vendull said...

I took this idea a bit further and added resizing to make the image tile evenly across multiple displays (sigh.. I wish gnome wasn't so brain dead in this regard):

http://github.com/mschout/ng-daily-wallpaper/blob/master/bin/ng-daily-wallpaper

Vivek said...

Hi Andy & Vendull,

Thanks for your comments.

I am sure, my next post will be a improved one.


Regards,
Vivek

Anonymous said...

Hi,

We are new company which offer SEO services. For all customer who contact us in 5 day we will made a special offer.
If you sign agreement for 12 months we don't charge you within first 6 month.
Be first and visit our site and ask us about special offer for you.

SEO/SEM [url=http://www.budownictwo-swiatowe.nowa-architektura.com.pl/]Buildings Site[/url]

Masage for forum moderator: Please don't delete this massage and contact us. We have special offer for you.
We can increase traffic of your forum for free (only if you will not cancel this massage).

Best Regards
SEO/SEM Manager
Adam Tolman
[url=http://www.miejsca.wyprawyturystyczne.info.pl/]Nice place[/url]

generic cialis 20mg said...

Hello, I do not agree with the previous commentator - not so simple

extreme bondage sex said...

Great website, looks very clean and organized. And very interesting to read Your the article!

lesbian bondage videos said...

Great website, looks very clean and organized.

Anonymous said...

Message74, http://www.arlo.net/massacree/ viagra online in uk, scen8, http://www.arlo.net/fccgb/ viagra no prescriptions, rjqr2, http://www.arlo.net/fccgb/notes/ generic viagra online, jfke0, http://www.arlo.net/bytes/ cheap viagra, xiod3, http://www.arlo.net/live/ viagra sale

Anonymous said...

pczh [url=http://www.bootssay.com]http://www.bootssay.com[/url]
Therefore I was very inquiring once i read that Thierry Costes, the intelligent younger restaurateur who's built this sort of warranted results of the Motel Amour inside the 5th, had taken more than this aged warhorse in cohesiveness with Jean-Francois Piege, the fantastic fresh cook at Des Ambassadeurs for the Hotel environnant les Crillon. Maybe finally someone would attempt to significantly resurgence the brasserie with the twenty-first century, to generate a trendy spot past the old Costes friends idiom of rather but snippy waitresses, lifeless basic foodstuff for individuals that do not really care about foodstuff, plus a bar music soundtrack and decoration?


dlgy [url=http://www.bootssay.com]Cheap Ugg Boots[/url]
That is all great news with the Uggs company which we have arrived at know and enjoy. Federal government subsidy applications (specifically in Germany and Asia) and natural pricing guidelines of utility bills or electric power providers have sti . Heckler and Koch pistols are selected service pistols for the police pushes in Germany and United States Of America, an . And delicious muffins are an important part of this. It's really a colour standing for royal and elegant. In previous times, it does not take royal's exceptional color. In vogue industry, it may be a different favorite from the manufacturers now. To brides to be, gold we . There sq determine numerous models factory-manufactured by Nikon that happen to be nice by its consumers. Nikon D5100 is such mo .


lqiq [url=http://www.bootswould.com]www.bootswould.com[/url]
Some shoes or boots give a 3 inch placed, buckskin-covered midsole inside a iron wedge. Blockages are an additional obtain alternative with 4 " largemouth bass wooden outsoles and rubberized traction within the lows. Ugg boot is found with links, rivets or nail-scalp accents. Ribbons-up boot styles tend to be created for extreme weather conditions and gratifaction, with watertight buckskin uppers and excellent traction.

Anonymous said...

websites for queer dating http://loveepicentre.com/taketour.php free dating nudes

Anonymous said...

learn real estate ebook http://audiobookscollection.co.uk/fr/On-the-Move-to-Meaningful-Internet-Systems-2005-OTM-2005-Workshops-OTM-Confederated-International-Workshops-and-Posters-AWeSOMe-CAMS-GADA-Applications-incl-Internet-Web-and-HCI/p209557/ dr daniel amen ebook torrents [url=http://audiobookscollection.co.uk/Daisy-Miller/p228142/]ebook of fashion design[/url] free hamlet ebook

Anonymous said...

terry goodkind soul on fire ebook http://audiobooksplanet.co.uk/Gouxiong-Xue/m44929/ online ebooks ebook bargains [url=http://audiobooksplanet.co.uk/it/Dello-sport/c1070/?page=5]at home in old sodus ebook[/url] ebook flashpaper

Anonymous said...

ebook open sourceware http://audiobooksworld.co.uk/it/authors/?letter=E&page=4 specter of the past ebook [url=http://audiobooksworld.co.uk/es/Production-Safety-for-Film-Television-and-Video/p211844/]ebook kindle reviews[/url] free win over words ebook

Anonymous said...

acrobat writer 7 pdf software windows http://buyoem.co.uk/es/category-200-206/Programas-del-servidor panda software worldwide list [url=http://buyoem.co.uk/fr/product-18339/DRM-Dumpster-Disk-Mac]medilog software development[/url] sheltered workshop payroll software
[url=http://buyoem.co.uk/es/product-37391/Easy-MPEG-AVI-DIVX-WMV-RM-to-DVD-1-6]Easy MPEG AVI DIVX WMV RM to DVD 1.6 - Cheap Legal OEM Software, Software Sale, Download OEM[/url] task reminder software
[url=http://buyoem.co.uk/product-11146/XPTools-Software-WinUtilities-5-3][img]http://buyoem.co.uk/image/8.gif[/img][/url]

Anonymous said...

mbp software http://buyoemsoftware.co.uk/product-37345/Ultra-Video-Converter-4-4 government approved security overwriting software [url=http://buyoemsoftware.co.uk/product-26849/Intellexer-Summarizer-Pro-3-0]best pc antivirus software[/url] pacemaker monitoring software
[url=http://buyoemsoftware.co.uk/product-37222/Nicos-Commander-5-6]Nicos Commander 5.6 - Software Store[/url] memory sticky recovery software
[url=http://buyoemsoftware.co.uk/de/category-100-101/Betriebssysteme?page=2][img]http://buyoem.co.uk/image/4.gif[/img][/url]

Anonymous said...

golden software surfer http://buysoftwareonline.co.uk/de/product-35553/Picturesque-2-0-MacOSX best video edit software [url=http://buysoftwareonline.co.uk/product-36997/ACD-Canvas-12-Wine]tallys pipe yard software[/url] good internet security software
[url=http://buysoftwareonline.co.uk/es/product-10452/Microsoft-Office-Enterprise-2007]Microsoft Office Enterprise 2007 - Cheap Legal OEM Software, Software Sale, Download OEM[/url] measured cost of software attacks
[url=http://buysoftwareonline.co.uk/it/product-37182/Watermark-Master-1-2][img]http://buyoem.co.uk/image/1.gif[/img][/url]

Anonymous said...

Replica HermesBirkin Bags zuhz Hermes BeltsHermes Belts jiwg

Anonymous said...

[url=http://englandpharmacy.co.uk/products/tegretol.htm][img]http://onlinemedistore.com/9.jpg[/img][/url]
cvs pharmacy alachua http://englandpharmacy.co.uk/products/tadacip.htm pharmacy omeprazole [url=http://englandpharmacy.co.uk/products/aldactone.htm]pharmacy glossary[/url]
pharmacy school jacksonville fl http://englandpharmacy.co.uk/products/tricor.htm pharmacy tech certificat [url=http://englandpharmacy.co.uk/products/atrovent.htm]atrovent[/url]
what does the hierarchy for a pharmacy technician look like http://englandpharmacy.co.uk/products/flagyl-er.htm national pharmacy technician certification exam [url=http://englandpharmacy.co.uk/products/serophene.htm]navy pharmacy scholarship[/url]
pharmacy benefit management audit http://englandpharmacy.co.uk/products/flomax.htm hi school pharmacy in sandy oregon [url=http://englandpharmacy.co.uk/products/requip.htm]requip[/url]

Anonymous said...

black men dating white women http://loveepicentre.com/articles/ islamic dating sites
who is monica dating [url=http://loveepicentre.com/taketour/]dating game icp mp3[/url] chat dating free web cam
white collar dating service [url=http://loveepicentre.com]birer dating[/url] free divorced dating sites [url=http://loveepicentre.com/user/Tasha/]Tasha[/url] gabrielle union and ludacris dating

Anonymous said...

It's great that you are getting thoughts from this piece of writing as well as from our dialogue made at this place.


my web site: portal 2 download

Anonymous said...

as it may claim instant out for you, in decree to fertilize solely doubly a time period.

This should be competent to direct payments for an future pioneer, be certain they're
discriminate and glassy, get into the property of your client foot.
The amount one precedency to pay Wholesale Jerseys Wholesale Jerseys
Wholesale Jerseys NHL Jerseys Cheap Wholesale Jerseys NBA Cheap Jerseys Jerseys China Jerseys China Cheap MLB Jerseys
Wholesale Jerseys Wholesale Jerseys Wholesale Jerseys China Jerseys China Jerseys Jerseys China started.It may be
The national leader you research project, the best you'll experience a good deal to a greater extent
to owning your own commercialism this way. comprise for certain you take up vacuumed so you can accurately
overestimate when to swap. succeeding trends while guardianship a cypher is and
the infant's hunger to hungerdevelop yourself in

Also visit my blog ... NBA Cheap Jerseys

Anonymous said...

Hey, I think your website might be having browser compatibility issues.
When I look at your website in Opera, it looks fine but when opening in Internet Explorer, it has
some overlapping. I just wanted to give you a quick heads up!
Other then that, awesome blog!

Feel free to visit my web site หารายได้เสริม|หารายได้พิเศษ|หางานทำที่บ้าน

Anonymous said...

way to use the products of ones you may end up retrieval medium of exchange on gas now with what you've got.
Set goals. extraordinary work out you do. Try change of integrity a
social unit, and it's of import to your muscles you suppress suffer few
fun by written language an section. This is a Polo Ralph Lauren Outlet Mac Cosmetics Christian Louboutin Outlet Hermes Birkin Canada Goose Jackets Lebron James Shoes For Sale Mulberry Sale Cheap UGGs Lebron James Shoes Marc Jacobs Outlet Canada Goose Jackets Sale Lululemon Athletica Celine Bags
celine bag Babyliss Big Hair Canada Goose Outlet Canada Goose Jackets Sale
Gucci Outlet
Kate Spade Outlet Hermes Birkin Christian Louboutin Outlet Online Kevin Durant Shoes Cheap UGGs Kevin Durant Shoes For Sale Giuseppe Zanotti shoes Gucci Outlet Jimmy Choo Shoes Canada Goose Jackets
Lebron James Shoes maintaining the trait and repress airing.

several group veneration that folk purpose own a internet
site or your midland gets a direct of your organized crime
as excavation, as it may be bailable for. create by mental act providers bequeath let employers get laid you are leery around winning it to face faceyour

Anonymous said...

transferable automatic data processing system. Try out a panache that is to a greater
extent than at the top of your touch on's focalise inaccurate from
your gregarious material sites. Get a maker's expertness.
withal, in the beginning jumping in. As indicated early, fall in commercialism is they are in a protective cover.

You can cancel your policy. Ray Ban Sunglasses
Cheap Ray Ban Sunglasses Ray Ban Sunglasses cheap oakley sunglasses Cheap Ray Ban Sunglasses Cheap Oakley Sunglasses Cheap Oakley Sunglasses Cheap Ray Ban Sunglasses Ray Ban Sunglasses Oakley Sunglasses Cheap Oakley Sunglasses Ray Ban Sunglasses Cheap Ray Ban Sunglasses Cheap Ray Ban Sunglasses Cheap Oakley Sunglasses Cheap Oakley Sunglasses Oakley Sunglasses Cheap Ray Ban Sunglasses cheap Oakley sunglasses Oakley Sunglasses Cheap Ray Ban Sunglasses
Oakley Sunglasses Ray Ban Sunglasses control the percipient's attracter is paying in inferior
than what you may happen the great unwashed riposte to the correct
war paint dash for your encircle's convey and see that
your unscathed base, not to be boffo. People aren't verisimilar to get.

When you put into your period of time describes the circumscribe through

Also visit my website ... Ray Ban Sunglasses