Created
August 21, 2015 02:36
-
-
Save foxiepaws/c95855f2d7e23d7d75b6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sub newsingle { | |
| my ($image, $style); | |
| for ($config->{select}) { | |
| do { | |
| # select a specific image from the list of walls based on | |
| # the toplevel config var "select". (0 indexed) | |
| my @walls = @{$config->{walls}}; | |
| $image = $walls[$_]; | |
| } when $_ > -1; | |
| default { | |
| # randomly select an image from the list of walls. | |
| my @walls = @{$config->{walls}}; | |
| $image = $walls[rand @walls]; | |
| } | |
| } | |
| # get which style we are going to use. | |
| if (defined($image->{style})) { | |
| $style = $image->{style}; | |
| } elsif (defined($config->{style})) { | |
| $style = $config->{style}; | |
| } else { | |
| $style = "centered"; | |
| } | |
| # fix the path using the above fix path implementation, and | |
| # display the image if it exists, or warn the user otherwise. | |
| for (fix_path $image->{file}) { | |
| system "${bgcommand} ${formats{$style}} ${_}" when -f; | |
| default { | |
| carp "file doesn't actually exist"; | |
| } | |
| } | |
| } | |
| sub single { | |
| # FIXME: Make this readable. | |
| my ($image, $imageh); | |
| $imageh = $config->{walls}[$config->{select}] if ($config->{select} > -1); | |
| $imageh = $config->{walls}[(floor(rand(scalar @{$config->{walls}})))] if ($config->{select} == -1); | |
| $image = $imageh->{file}; | |
| $image = ( defined($config->{dir}) ? $config->{dir} : $ENV{HOME} ) . "/".$imageh->{file} if ($imageh->{file} =~ /^[^~\/]/); | |
| my $style = defined($imageh->{style}) ? | |
| $imageh->{style} | |
| : defined($config->{style}) ? | |
| $config->{style} | |
| : "centered"; | |
| system "$bgcommand ".$formats{$style}." $image" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment