flickr + xscreensaver = fun

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.

  1. Get
    xscreensaver-getimage-flickr
    .
  2. Go to www.flickr.com and get an API key.
  3. Edit the xscreensaver-getimage-flickr file and replace the PUTKEYHERE on line 31 with the key you obtained.
  4. Backup /usr/bin/xscreensaver-getimage-file.
  5. Copy xscreensaver-getimage-flickr to /usr/bin/xscreensaver-getimage-file.
  6. 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
  7. Use CPAN to install Flickr::API.

    sudo perl -MCPAN -e 'install Flickr::API'
  8. Now set which Flickr user’s images you want to display.
    Edit ~/.xscreensaver and set imageDirectory: 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.

5 thoughts on “flickr + xscreensaver = fun”

  1. 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”;
    }
    }

  2. 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!

  3. 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

Comments are closed.