-
Notifications
You must be signed in to change notification settings - Fork 0
/
change_desktop.pl
37 lines (33 loc) · 950 Bytes
/
change_desktop.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/perl
#
use strict;
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;
}
}
my $uri = $download_link;
my $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...
#
my $tempfile = "/home/dvf1976/Pictures/$file_name[1]-$file_name[2]-$file_name[4].jpg";
#
$mech->get( $uri, ':content_file' => $tempfile );
#
#
if ( -e $tempfile ){
my $statement = "gconftool-2 --type string --set /desktop/gnome/background/picture_filename $tempfile";
warn $statement;
system($statement);
}