Yesterday I fixed the livejournal script that comes with xscreensaver to work with any rss feed. No more boring fortune output when xscreensaver randomly picks Noseguy. Instead, a random quote from your favorite rss feed is displayed.
Today I hacked up JWZ’s xscreensaver-getimage-file perl script to pull images from Flickr instead of a file or directory on your computer.
It was easy to do using Flickr::API and LWP::UserAgent.
glscreensaver, blitspin, decayscreen, distort, and any other xscreensaver that normally would pull an image from a directory, will now pull a random photo from any users public flickr photos.
Here is how to install it on an ubuntu hoary system. This is probably true for warty, and debian, and many other distributions.
-
Get
xscreensaver-getimage-flickr. - Go to www.flickr.com and get an API key.
- Edit the xscreensaver-getimage-flickr file and replace the PUTKEYHERE on line 31 with the key you obtained.
- Backup /usr/bin/xscreensaver-getimage-file.
- Copy xscreensaver-getimage-flickr to /usr/bin/xscreensaver-getimage-file.
-
Install some required packages first. CPAN will catch these, but I prefer to install the distribution packages.
sudo apt-get install libsoap-lite-perl libwww-perl
-
Use CPAN to install Flickr::API.
sudo perl -MCPAN -e 'install Flickr::API'
-
Now set which Flickr user’s images you want to display.
Edit ~/.xscreensaver and setimageDirectory: user
This is the catch, because the xscreensaver-demo configuration screen will not let you specify a non existant directory. If you launch xscreensaver-demo and start setting things you will get “user doesn’t not exist” errors, where user is the user you set in .xscreensaver. In Ubuntu, this is the System->Preferences->Screensaver display, so beware of this strangeness.
Now pick some screensavers like the mentioned glslideshow or blitspin.
Current bugs:
It fills /tmp with a bunch of jpg files.
xscreensaver-demo complains.
probably many more.
Excellent script, sir.
“I have seen some nice instructions to enable xscreensaver load images from flickr; the script that is pointed to is written in perl.” – http://sunim.plus.com/virtuality/2005/04/18/tiger-vs-linux/
Great job! However, it appears flickr has changed the url format. The following patch should work.
*** xscreensaver-getimage-flickr 2006-01-14 07:54:09.000000000 -0600
— xscreensaver-getimage-file 2006-01-14 08:23:34.000000000 -0600
***************
*** 129,135 ****
# print $photo->{$attr}.”\t”;
#}
#implement size options for mstb
! push @urls, “http://photos”.$photo->{server}.”.flickr.com/”.$photo->{id}.”_”.$photo->{secret}.”.jpg”;
}
}
— 129,136 —-
# print $photo->{$attr}.”\t”;
#}
#implement size options for mstb
! #push @urls, “http://photos”.$photo->{server}.”.flickr.com/”.$photo->{id}.”_”.$photo->{secret}.”.jpg”;
! push @urls, “http://static.flickr.com/”.$photo->{server}.”/”.$photo->{id}.”_”.$photo->{secret}.”.jpg”;
}
}
This comment is slightly off-topic, but for gentoo – you can generate an ebuild for Flickr::API and its dependencies using the ‘g-cpan’ tool.
As root or portage user:
emerge g-cpan
g-cpan -i ‘Flickr::API’
emerge perl-gcpan/FlickrAPI
Hope this helped someone out!
Thanks for the helpful comments. Patch as well as gentoo ebuild MUCH appreciated 😀
Using only images from a single user isn’t so funny at all.
I worte some dirty changes.
Maybe you can find a way to ‘configure’ the mode per xscreensaver directory.
e.g.: user:test
or group:xyz
or tag:ccc
And please aply the patch to your script
# begin search by tag
my $response = $flickrapi->execute_method(‘flickr.photos.search’, {
‘tags’ => $user,
});
# ende search by tag
# start search by group key
my $response = $flickrapi->execute_method(‘flickr.groups.pools.getPhotos’, {
‘group_id’ => $user,
});
# end search by group key
#org search by username
# my $response = $flickrapi->execute_method(‘flickr.people.findByUsername’, {
# ‘username’ => $user,
# });
# my $nsid = $response->{tree}->{children}->[1]->{attributes}->{nsid};
# $response = $flickrapi->execute_method(‘flickr.people.getPublicPhotos’, {
# ‘user_id’ => $nsid,
# });
#ende org search by username