From c52b258b86be4c98f00dd9e0dc686139d955c9de Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Sat, 21 Feb 2009 20:33:52 +1300 Subject: [PATCH] Allow the directory to specified in the config file. --- lib/Display/Plugins/Photo/Directory.pm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Display/Plugins/Photo/Directory.pm b/lib/Display/Plugins/Photo/Directory.pm index 93a5134..f72760b 100644 --- a/lib/Display/Plugins/Photo/Directory.pm +++ b/lib/Display/Plugins/Photo/Directory.pm @@ -5,7 +5,7 @@ use Clutter; use POE::Session; use FindBin qw/$Bin/; -my $directory = "$Bin/test_images"; +my $default_directory = "$Bin/test_images"; sub new { my $proto = shift; @@ -13,6 +13,9 @@ sub new { my $self = $class->SUPER::new(@_); + $self->{'directory'} = + $self->{'config'}{'_config'}{'plugins'}{'Directory'}{'Directory'} || $default_directory; + bless ($self, $class); $self->{'kernel'}->yield('find_photo'); return $self; @@ -21,13 +24,13 @@ sub new { sub find_photo { my $self = shift; - if (opendir(DIR, $directory)) { + if (opendir(DIR, $self->{'directory'})) { my @files = readdir(DIR); closedir DIR; - $self->{'kernel'}->yield('display_photo', join("/", $directory, $files[rand @files])); + $self->{'kernel'}->yield('display_photo', join("/", $self->{'directory'}, $files[rand @files])); } else { - warn "Failed to open $directory for reading: $!\n"; + warn "Failed to open $self->{'directory'} for reading: $!\n"; } } -- 2.30.2